Not Warning About Invalid C Code

Hi all,

This program:

struct t {
   unsigned long l;
};

void g(struct t *);

void bork() {
   const unsigned long v = 'vcgt';
   struct t A = { v };

   g(&A);
}

Should warn for C89/C90, but doesn't even with -pedantic set. Here's what GCC produces:

$ gcc t.c -pedantic -c
t.c: In function 'bork':
t.c:9: warning: initializer element is not computable at load time

Without the -pedantic flag, gcc accepts this without warning.

-bw

Hi all,

This program:

struct t {
   unsigned long l;
};

void g(struct t *);

void bork() {
   const unsigned long v = 'vcgt';
   struct t A = { v };

   g(&A);
}

Should warn for C89/C90, but doesn't even with -pedantic set. Here's
what GCC produces:

$ gcc t.c -pedantic -c
t.c: In function 'bork':
t.c:9: warning: initializer element is not computable at load time

Without the -pedantic flag, gcc accepts this without warning.

This is because Sema::CheckInitializer() doesn't type check structs yet (for any dialect).

Finishing type checking for initializers is on the short list...

snaroff