https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96952
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- __has_builtin does what is documented: The special operator @code{__has_builtin (@var{operand})} may be used in constant integer contexts and in preprocessor @samp{#if} and @samp{#elif} expressions to test whether the symbol named by its @var{operand} is recognized as a built-in function by GCC in the current language and conformance mode. It evaluates to a constant integer with a nonzero value if the argument refers to such a function, and to zero otherwise. __builtin_thread_pointer is recognized as a built-in function by GCC, so you get 1 from __has_builtin. It is not feasible to have at preprocessing time complete knowledge of the details how the builtin will be lowered (if at all), expanded (if at all), whether it needs any optabs etc. A lot of those details are also dependent on the builtin arguments and other details (e.g. from which function it is called, what function specific options are enabled etc.).