This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Should gcc give warning for this case?
- From: Qun-Ying <zhu dot qunying at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sat, 28 Apr 2012 23:14:26 -0700
- Subject: Should gcc give warning for this case?
For the simple program, forward.c:
#include <stdio.h>
typedef struct _item_st {
int data;
struct item_st *next;
} item_t;
int
main (int argc, char *argv[])
{
item_t head = {0, NULL};
head.data = 1;
printf ("head.data: %d ptr: %p\n", head.data, (void *)head.next);
return 0;
}
I compile with gcc 4.7.0 with:
gcc -Wall -pedantic -std=c99 forward.c
No warning at all. Should gcc warn about the *next pointer points to
an unknown structure? I know it is allow by the standard, but most of
the case, it indicates some error in the code.
--
Qun-Ying