[Bug c++/60512] would be useful if gcc implemented __has_feature similary to clang

acoplan at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jan 3 16:41:01 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60512

Alex Coplan <acoplan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acoplan at gcc dot gnu.org

--- Comment #9 from Alex Coplan <acoplan at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #6)
> (In reply to Manuel López-Ibáñez from comment #5)
> > AFAIU, it will be welcome if someone implements it.
> 
> I see no need to add __has_feature given that it contradicts the
> recommendations of the C++ committee, and that GCC already defines the
> recommended feature test macros that can be used without __has_feature.

I think it's worth noting that __has_feature can be used to check for more than
just C++ language features. To quote the clang documentation
(https://clang.llvm.org/docs/LanguageExtensions.html):

> Another use of __has_feature is to check for compiler features not related to the language standard, such as e.g. AddressSanitizer.

LLVM users can check whether ASan is enabled using
__has_feature(address_sanitizer). Similarly one can query e.g.
__has_feature(thread_sanitizer).

I think it would be good for the alignment between GCC and LLVM if GCC were to
implement this extension.


More information about the Gcc-bugs mailing list