This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]