https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102936
Bug ID: 102936 Summary: Excessive warnings about passing NULL for an "%s" specifier Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: eyalroz1 at gmx dot com Target Milestone: --- Consider the following program: #include <stddef.h> __attribute__((format(__printf__, 2, 3))) int sprintf_(char* buffer, const char* format, ...) { (void) buffer; (void) format; return 0; } int main() { char buffer[100]; return sprintf_(buffer, "%s", NULL); } when compiled with `-W -Wall`, we get two warnings: a.c:15:28: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘void *’ [-Wformat=] a.c:15:9: warning: ‘%s’ directive argument is null [-Wformat-overflow=] The second warning seems legit. However - I don't think I should be getting the first warning. If I can write: char* ptr = NULL; and not get a type warning, I don't see why I should get one for passing NULL to the function.