public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* This should at least give a warning even if it is legal C
@ 2004-02-01 19:35 Jason Wilson
  2004-02-01 19:39 ` Andrew Pinski
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Wilson @ 2004-02-01 19:35 UTC (permalink / raw)
  To: gcc-bugs

[-- Attachment #1: Type: text/plain, Size: 196 bytes --]

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.


[-- Attachment #2: bad.c --]
[-- Type: text/plain, Size: 130 bytes --]


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

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

[-- Attachment #3: Type: text/plain, Size: 173 bytes --]



[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)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: This should at least give a warning even if it is legal C
  2004-02-01 19:35 This should at least give a warning even if it is legal C Jason Wilson
@ 2004-02-01 19:39 ` Andrew Pinski
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2004-02-01 19:39 UTC (permalink / raw)
  To: Jason Wilson; +Cc: gcc-bugs, Andrew Pinski


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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-01 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-01 19:35 This should at least give a warning even if it is legal C Jason Wilson
2004-02-01 19:39 ` Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).