This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: This should at least give a warning even if it is legal C
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Jason Wilson <jasonwilson at alum dot mit dot edu>
- Cc: gcc-bugs at gcc dot gnu dot org, Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Sun, 1 Feb 2004 11:39:43 -0800
- Subject: Re: This should at least give a warning even if it is legal C
- References: <D03812AD-54ED-11D8-9BAF-000393D150EE@alum.mit.edu>
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)