This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Missing warning
- From: Torbjorn Granlund <tg at gmplib dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 10 Oct 2012 09:48:26 +0200
- Subject: Missing warning
Using recent versions of gcc, and the options -O -Wall the test case
below should provove a warning from the compiler of an unitialised
variable, 'errcode'.
Gcc releases:
* gcc version 4.7.1 (Debian 4.7.1-2)
* gcc version 4.7.0 20120225 (experimental) (FreeBSD Ports Collection)
* gcc version 4.6.4 20120309 (prerelease) (FreeBSD Ports Collection)
(OK, I realise none is an official release, but I feel confident enough that
this bug is in the official releases too.)
Command:
* gcc -O -Wall foo.c
Expected behaviour:
A warning diagnostic message.
Obsorved behaviour:
No diagnostic output.
Test case foo.c:
int
variable_errcode_is_uninitialised (const char *s)
{
int errcode;
for (;;)
{
unsigned c = *s++;
if (c == 0)
break; /* errcode uninitialised on this path */
if (c < '0')
{
errcode = -1;
break; /* errcode initialised on this path */
}
}
return errcode;
}
--
TorbjÃrn