This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37148] New: -Wunintialized fails in the face of conditional assignment.
- From: "thutt at vmware dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Aug 2008 13:31:34 -0000
- Subject: [Bug c/37148] New: -Wunintialized fails in the face of conditional assignment.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Although I demonstrated this using 4.1.2 on my host, it probably affects
other versions as well.
As the following code shows:
gcc -c -O1 -Wall -Werror uninitialized-warning.c
extern void called_function(unsigned p);
extern unsigned g;
void
f0(unsigned parm)
{
unsigned v;
if (parm == 0) {
v = 4;
}
called_function(v);
}
void
f1(unsigned parm)
{
unsigned v;
if (parm == 0) {
v = 4;
} else {
g = 0;
}
called_function(v);
}
void
f2(unsigned parm)
{
unsigned v;
called_function(v);
}
gcc does not produce the 'uninitialized' warning when the automatic
variable is conditionally assigned.
This gives a very bad false sense of security that the automatic
variables are indeed initialized.
--
Summary: -Wunintialized fails in the face of conditional
assignment.
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: thutt at vmware dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37148