* "uninitialized variable" warning from compiler
[not found] ` <448a67a0910260705l3f0f9e7ek857e40bac6a830ab@mail.gmail.com>
@ 2009-10-30 1:16 ` Uma shankar
2009-10-30 8:42 ` Ian Lance Taylor
0 siblings, 1 reply; 2+ messages in thread
From: Uma shankar @ 2009-10-30 1:16 UTC (permalink / raw)
To: gcc
Hi,
I have few questions about inbuilt mechanism of gcc/g++ for
warning about uninitialized variable.
I am interested in cases where compiler is unable to warn. I am
aware that all the known bugs about warning-failure are
mentioned at bugzilla http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639
a) The compiler activates the warning mechanism only if optimisation
is enabled at compilation time with -O option. For all the bugs that
I went through at bugzilla, the failure is not -O level dependent.
The warning-failure occurs for all levels of optimisation. So, I
believe this is the general case.
But then I came across the following failure case.
////////////////////
#include <stdio.h>
int Check(int *a)
{
if (*a == 0)
{
printf("This is sample \n");
}
return *a;
}
int main()
{
int call;
Check(&call);
return 0;
}
/////////////////////
This one fails to warn when compiled with any level below 3.
With -O3, gcc is able to warn.
Can someone tell me which is the corresponding bug logged at bugzilla ?
Are there any more such bugs which disappear when compiled with
specific -O level ?
b) Are there any known "fail to do uninitialised-warning" gcc bugs
which are language-dependent ? I mean bugs which occur only in C++ ,
but not in C. ( Bugs which arise out of C++ language features/syntax. ) .
If so, I would like to know.
Elsewhere, someone pointed out to me that these are not "bugs", but occur
due to tradeoff in compiler against false positive warnings. I am
referring them
as "bugs" only because compiler hackers do so.
thanks for your time
Uma shankar
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: "uninitialized variable" warning from compiler
2009-10-30 1:16 ` "uninitialized variable" warning from compiler Uma shankar
@ 2009-10-30 8:42 ` Ian Lance Taylor
0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2009-10-30 8:42 UTC (permalink / raw)
To: Uma shankar; +Cc: gcc
Uma shankar <shankar.vk@gmail.com> writes:
> a) The compiler activates the warning mechanism only if optimisation
> is enabled at compilation time with -O option. For all the bugs that
> I went through at bugzilla, the failure is not -O level dependent.
> The warning-failure occurs for all levels of optimisation. So, I
> believe this is the general case.
>
> But then I came across the following failure case.
>
> ////////////////////
> #include <stdio.h>
> int Check(int *a)
> {
> if (*a == 0)
> {
> printf("This is sample \n");
> }
> return *a;
> }
> int main()
> {
> int call;
> Check(&call);
> return 0;
> }
> /////////////////////
>
> This one fails to warn when compiled with any level below 3.
> With -O3, gcc is able to warn.
>
> Can someone tell me which is the corresponding bug logged at bugzilla ?
>
> Are there any more such bugs which disappear when compiled with
> specific -O level ?
>
> b) Are there any known "fail to do uninitialised-warning" gcc bugs
> which are language-dependent ? I mean bugs which occur only in C++ ,
> but not in C. ( Bugs which arise out of C++ language features/syntax. ) .
> If so, I would like to know.
>
> Elsewhere, someone pointed out to me that these are not "bugs", but occur
> due to tradeoff in compiler against false positive warnings. I am
> referring them
> as "bugs" only because compiler hackers do so.
This message is also not appropriate for gcc@gcc.gnu.org, but is
appropriate for gcc-help@gcc.gnu.org.
gcc is known to be inconsistent about when it issues warnings about
uninitialized variables. This is not a good thing. It is a
consequence of the fact that gcc issues those warnings based on the
implementation of different optimizations.
I'm not aware of any attempts to characterize precisely when gcc warns
and when it does not. Any such characterization would have to be
updated for each new release in any case.
Ian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-10-30 4:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <448a67a0910260655g2fe59e61g209bd1cb4122fd35@mail.gmail.com>
[not found] ` <448a67a0910260705l3f0f9e7ek857e40bac6a830ab@mail.gmail.com>
2009-10-30 1:16 ` "uninitialized variable" warning from compiler Uma shankar
2009-10-30 8:42 ` Ian Lance Taylor
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).