GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc

Fix __has_builtin for __builtin_bitreverseg and __builtin_bswapg

Ensures __has_builtin correctly reports availability of __builtin_bitreverseg and __builtin_bswapg.

This commit corrects the __has_builtin operator to properly recognize the __builtin_bitreverseg and __builtin_bswapg magic keywords. These builtins were recently added, but support for checking their availability via __has_builtin was missing, leading to incorrect code generation or compilation errors in certain scenarios.

In Details

The names_builtin_p function in both c-decl.cc and cp-objcp-common.cc was updated to recognize RID_BUILTIN_BITREVERSEG and RID_BUILTIN_BSWAPG. This ensures that __has_builtin correctly queries the existence of these magic keyword builtins, which are resolved early in the front-end.

For Context
__has_builtin
A preprocessor operator that checks if a specified builtin function is supported by the compiler, allowing for conditional compilation.
magic keyword builtin
A special function recognized directly by the compiler's front-end, often not implemented as a standard library function, providing direct access to compiler or hardware features.
RID_BUILTIN_BITREVERSEG
Internal compiler representation for the __builtin_bitreverseg magic keyword builtin.
RID_BUILTIN_BSWAPG
Internal compiler representation for the __builtin_bswapg magic keyword builtin.
Filed Under: cc++builtinpreprocessor