This is the mail archive of the gcc-bugs@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]

Re: This should at least give a warning even if it is legal C



struct foobar { int a; struct foobar *b; };

int main (int argc, char **argv)
{
  struct foobar *bar = bar->b;
  return 0;
}

This is caught in an unreleased version of gcc (3.4.0), which should be release within the
next four months (but no promises of the release date).


You have to compile with optimization and -Wuninitialized to get the warning though.

Thanks,
Andrew Pinski


On Feb 1, 2004, at 11:35, Jason Wilson wrote:


I'm not sure if this program is legal C or not but it is certainly a bad program that could be caught by the compiler. Compiling without optimization leads to a bus error as one might expect.

<bad.c>

[Jason-Wilsons-G4:~] jason% gcc -v
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1495)


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