Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
- Subject: Re: Compiler Weirdness and possible bug ( was Re: Controlling optimization level per function )
- From: "Sean McBride" <email@hidden>
- Date: Sat, 10 Jul 2010 23:09:33 -0400
Jocelyn Houle (email@hidden) on 2010-07-10 08:11 said:
>According to:
> http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
>GCC has a -Winit-self which, when using with -Wuninitialized, should
>have warned you.
>
>I looked back in the previous GCC versions doc, and found it even in GCC 4.2:
> http://gcc.gnu.org/onlinedocs/gcc-4.2.0/gcc/Warning-Options.html
>(and even earlier). But using it doesn't seem to work.
>
>So even though the C/C++ spec might not require a warning, the GCC folks
>clearly wanted to allow it, but it seems broken.
gcc-4.2 warns for me:
$ gcc-4.2 -Wuninitialized -O1 test.c
$ gcc-4.2 -Wuninitialized -O1 -Winit-self test.c
test.c: In function ‘main’:
test.c:3: warning: ‘x’ is used uninitialized in this function
Also, the clang static analyzer warns:
warning: Assigned value is garbage or undefined
int x = x;
^ ~
Of course, it doesn't support C++, so that doesn't help Eric.
clang, the compiler, (trunk r108066) does not seem to warn, which is a pity.
Sean
--
"When the winds of change are blowing, some people are building shelters
and others are building windmills" - Chinese proverb
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden