See: http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01601.html
Note that this will be incompatible with what clang uses (http://clang.llvm.org/docs/AddressSanitizer.html#has_feature) Clang will never use a CPP macro (I've lost this battle a year ago). Just FYI. I don't know how much compatibility we want and can achieve.
(In reply to comment #1) > Note that this will be incompatible with what clang uses > (http://clang.llvm.org/docs/AddressSanitizer.html#has_feature) > Clang will never use a CPP macro (I've lost this battle a year ago). > > Just FYI. I don't know how much compatibility we want and can achieve. has feature will most likely not be implemented in GCC so CPP macro is correct for GCC. If clang wants to have a non-standard way of doing CPP macro for features, that is up to them.
FTR: my conversation with clang on this topic. http://comments.gmane.org/gmane.comp.compilers.clang.scm/42610 From Diego: I don't know of any current effort in this area for GCC. If __has_feature() is desirable, patches documenting and implementing it would be welcome. The GCC pre-processor is jointly maintained by all the FE maintainers. I would start there. If we end up implementing a macro, may I ask it to be named ADDRESS_SANITIZER? This name is already used in a few places (Chromium, WebKit, etc).
(In reply to comment #3) > > If we end up implementing a macro, may I ask it to be named ADDRESS_SANITIZER? > This name is already used in a few places (Chromium, WebKit, etc). It should have `_' prefix.
Then it should probably *not* be named _ADDRESS_SANITIZER (imagine a user trying to understand why ADDRESS_SANITIZER works for him with clang, where he added -DADDRESS_SANITIZER=1 manually, and dpoes not work with gcc where he saw the documentation saying about _ADDRESS_SANITIZER) Maybe something with GCC in the name? _GCC_ADDRESS_SANITIZER?
Author: hjl Date: Wed Nov 21 20:20:42 2012 New Revision: 193704 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193704 Log: Define __SANITIZE_ADDRESS__ for -fsanitize=address PR c/55397 * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Define __SANITIZE_ADDRESS__ for flag_asan. Modified: trunk/gcc/ChangeLog trunk/gcc/cppbuiltin.c
Fixed.