https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108893
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Jonny Grant from comment #0) > > void f(const char * const str) __attribute__((access(read_only, 1))); > void f(const char * const str) > { > __builtin_puts(str); > } > > int main() > { > const char * a = nullptr; > f(a); > } > > Tested on trunk in C++ > https://godbolt.org/z/rc8G6bePq The goldbolt testcase does not match the above testcase. In fact using the above testcase works and gives us the warning for both -fanalyzer and -Wnonnull: ``` In function 'void f(const char*)', inlined from 'int main()' at <source>:10:6: <source>:4:19: warning: use of NULL where non-null expected [CWE-476] [-Wanalyzer-null-argument] 4 | __builtin_puts(str); | ~~~~~~~~~~~~~~^~~~~ 'int main()': event 1 | | 10 | f(a); | | ^ | | | | | (1) inlined call to 'f' from 'main' | +--> 'void f(const char*)': event 2 | | 4 | __builtin_puts(str); | | ~~~~~~~~~~~~~~^~~~~ | | | | | (2) argument 1 NULL where non-null expected | <built-in>: In function 'int main()': <built-in>: note: argument 1 of 'int __builtin_puts(const char*)' must be non-null In function 'void f(const char*)', inlined from 'int main()' at <source>:10:6: <source>:4:19: warning: argument 1 null where non-null expected [-Wnonnull] <source>:4:19: note: in a call to built-in function 'int __builtin_puts(const char*)' ```