https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108871
--- Comment #8 from Jonny Grant <jg at jguk dot org> --- Another test case. https://godbolt.org/z/qss7jj51x I noticed when not using -fanalyzer gcc still warns about __builtin_puts being passed NULL. However gcc doesn't warn about my own function with attribute nullptr. Maybe I'm missing something. With puts() it gives a nice warning In function 'void f2(const char*)', inlined from 'void f1(const char*)' at <source>:22:7, inlined from 'int main()' at <source>:28:7: <source>:11:19: warning: argument 1 null where non-null expected [-Wnonnull] 11 | __builtin_puts(str); | ~~~~~~~~~~~~~~^~~~~ // -std=c++23 -O1 -Wnonnull -Wall // Test case that shows a difference in behavour, // __builtin_puts generates a warning but not f1() // Note, not using -fanalyzer // Change this to 1 to see nonnull warning #define USE_PUTS 0 void f2(const char * str) { #if USE_PUTS __builtin_puts(str); #else char a = *str; __builtin_printf("%c", a); #endif } void f1(const char * const str) __attribute__ ((nonnull)); void f1(const char * const str) { f2(str); } int main() { const char * a = nullptr; f1(a); }