Should gcc give warning for this case?

2012-04-29 Thread Qun-Ying
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;

Re: Should gcc give warning for this case?

2012-04-29 Thread Miles Bader
Qun-Ying zhu.quny...@gmail.com writes: 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. Hmm? Where do you expect to warn? You never dereference the

Re: Should gcc give warning for this case?

2012-04-29 Thread Jonathan Wakely
This question is not appropriate on this mailing list, questions about using GCC should be sent to the gcc-h...@gcc.gnu.org list, please take any follow up there instead, thanks. On 29 April 2012 07:14, Qun-Ying wrote: No warning at all.  Should gcc warn about the *next pointer points to an