http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55289
--- Comment #44 from Jack Howarth <howarth at nitro dot med.uc.edu> 2012-11-15 17:53:40 UTC --- Posted the final revision of the patch that now properly handles static linkage options with -faddress-sanitizer... http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01285.html For example... % gcc-fsf-4.8 -faddress-sanitizer -O1 -fno-omit-frame-pointer -g -static-libstdc++ -o use-after-free use-after-free.c % otool -L ./use-after-free ./use-after-free: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.12.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) /sw/lib/gcc4.8/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) links in libstdc++.a while... % gcc-fsf-4.8 -faddress-sanitizer -O1 -fno-omit-frame-pointer -g -static-libgcc -o use-after-free use-after-free.c % otool -L ./use-after-free ./use-after-free: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.12.0) /sw/lib/gcc4.8/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.17.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) links libstdc++.dylib. The standard linkage with... % gcc-fsf-4.8 -faddress-sanitizer -O1 -fno-omit-frame-pointer -g -o use-after-free use-after-free.c % otool -L ./use-after-free ./use-after-free: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.12.0) /sw/lib/gcc4.8/lib/libasan.0.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) /sw/lib/gcc4.8/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) doesn't need to be directly linked against libstdc++ because libasan.0.dylib already is... % otool -L /sw/lib/gcc4.8/lib/libasan.0.dylib /sw/lib/gcc4.8/lib/libasan.0.dylib: /sw/lib/gcc4.8/lib/libasan.0.dylib (compatibility version 1.0.0, current version 1.0.0) /sw/lib/gcc4.8/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.17.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) /sw/lib/gcc4.8/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)