title: Clang with -faddress-sanitizer on Windows
body: <p>My intent is to use <code>Clang</code> as a replacement for <code>Valgrind</code> on Windows to find buffer overflows, dynamic memory misuse etc. in C/C++ programs that I've written. I have successfully built Clang following the instructions provided <a href="https://stackoverflow.com/questions/9427356/how-to-compile-clang-on-windows">here</a>.</p>
  
  <p>I attempted to compile a simple C program with the -faddress-sanitizer option (as specified <a href="http://clang.llvm.org/docs/AddressSanitizer.html" rel="noreferrer">here</a>) and the following the error is thrown -</p>
  
  <pre><code>gcc.exe: error: unrecognized command line option '-faddress-sanitizer'
  Using built-in specs.
  COLLECT_GCC=C:/MinGW/bin/gcc.exe
  Target: mingw32
  Configured with: ../gcc-4.7.0/configure --enable-languages=c,c++,ada,fortran,objc,obj-      c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
  Thread model: win32
  gcc version 4.7.0 (GCC)
  clang: error: assembler (via gcc) command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>Why is clang (as I understand it) invoking GCC? Of course GCC does not support the -faddress-sanitizer option. </p>
  
  <p>I am really excited at the possibility of using this as I've been trying to find a good (free) substitute for Valgrind for a while. Can someone please help?</p>