title: How to resolve `clang: error: unsupported option '-fsanitize=leak'` on apple devices
body: <p>I am trying to run a simple leak check program.</p>
  <pre><code>#include &lt;iostream&gt;
  
  int main()
  {
     
      double *ptr = new double(3.14);
  
  
  }  
  </code></pre>
  <p>using the command
  <code> g++ -g -fsanitize=leak -o main main.cpp</code></p>
  <p>and I get the following error:</p>
  <p><code>clang: error: unsupported option '-fsanitize=leak' for target 'x86_64-apple-darwin20.1.0'</code></p>
  <p>I stopped using the clang that comes with Xcode and installed clang/LLVM using homebrew.</p>
  <pre><code>$ which clang++
  /usr/local/opt/llvm/bin/clang++
  </code></pre>
  <pre><code>clang++ --version
  clang version 11.0.0
  Target: x86_64-apple-darwin20.1.0
  Thread model: posix
  InstalledDir: /usr/local/opt/llvm/bin
  </code></pre>
  <p>EDIT: When I was using apple clang, g++ used to default to clang++. Apparently that changed when I installed llvm/clang. Thanks to @cigien  for pointing it out. g++ still uses default to the compiler that that comes with Apple clang.</p>
  <pre><code> g++ --version
  Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
  Apple clang version 12.0.0 (clang-1200.0.32.27)
  Target: x86_64-apple-darwin20.1.0
  Thread model: posix
  InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  </code></pre>