https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66516
Bug ID: 66516 Summary: missing diagnostic on taking the address of a builtin function Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Gcc accepts without warning code that takes the address of builtin functions and calls such functions through pointers. Some such code links and even runs successfully while other such code fails to link. For example, code that compiles, links and runs: $ cat z.c && gcc -Wall z.c && ./a.out extern int printf (const char*, ...); unsigned long strlen (const char*); int main (void) { unsigned long (*p)(const char*) = &__builtin_strlen; printf ("&__builtin_strlen = %p\n" "&strlen = %p\n", p, &strlen); } &__builtin_strlen = 0x400430 &strlen = 0x400430 Code that compiles but doesn't link involves builtins that don't have corresponding libc functions. Clang rejects all such code with an error similar to the following: z.c:6:40: error: builtin functions must be directly called unsigned long (*p)(const char*) = &__builtin_strlen; ^ 1 error generated. It seems that gcc should reject all code that attempts to take the address of a builtin the same way Clang does.