https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85419
Bug ID: 85419 Summary: Incorrect determination of null pointer constant Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: terra at gnome dot org Target Milestone: --- Created attachment 43949 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43949&action=edit Preprocessed source code Priority: low #include <stdio.h> int main (int argc,char **argv) { printf ("%p\n", 0 ? (void *restrict)0 : (int *)0); return 0; } As I read C99's section 6.3.2.3, (void *restrict)0 is *not* a null pointer constant. I am reading section 6.5.15 as saying the ?: is valid with type void *restrict. %p is valid for such a pointer. gcc disagrees: # gcc -std=c99 -pedantic -Wall t.c t.c: In function ‘main’: t.c:6:3: warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int *’ [-Wformat=] printf ("%p\n", 0 ? (void *restrict)0 : (int *)0); ^ I.e., it thinks (void *restrict)0 is a null pointer constant. Hence ?: becomes an int* and %p isn't valid for that in a pedantic sense. Removing the "restrict" clearly makes the program invalid in a pedantic sense. I.e., Section 6.7.3 #7 is wrong. Details: stock OpenSuSE 42.3