[Bug 1249505] [NEW] clang fails to report uninitialized local variable
Kevin Grittner
kgrittn at ymail.com
Fri Nov 8 22:20:08 UTC 2013
Public bug reported:
$ lsb_release -rd
Description: Ubuntu 12.10
Release: 12.10
$ apt-cache policy clang
clang:
Installed: 3.0-6ubuntu3
Candidate: 3.0-6ubuntu3
Version table:
*** 3.0-6ubuntu3 0
500 http://us.archive.ubuntu.com/ubuntu/ quantal/universe amd64 Packages
100 /var/lib/dpkg/status
With source file named warning_test.c in the current working directory,
containing this:
int warning_test(int a);
int warning_test(int a)
{
int result;
if (a == 1)
result = 1;
return result;
}
... I compiled with this command line:
clang -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-
after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-
security -fno-strict-aliasing -fwrapv -g -D_GNU_SOURCE -c -o
warning_test.o warning_test.c -MMD -MP
I expected:
warning_test.c:9:9: warning: variable 'result' is uninitialized when used here [-Wuninitialized]
return result;
^~~~~~
warning_test.c:4:14: note: initialize the variable 'result' to silence this warning
int result;
^
= 0
1 warning generated.
I got a clean compile (no warnings).
** Affects: gcc-defaults (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1249505
Title:
clang fails to report uninitialized local variable
Status in “gcc-defaults” package in Ubuntu:
New
Bug description:
$ lsb_release -rd
Description: Ubuntu 12.10
Release: 12.10
$ apt-cache policy clang
clang:
Installed: 3.0-6ubuntu3
Candidate: 3.0-6ubuntu3
Version table:
*** 3.0-6ubuntu3 0
500 http://us.archive.ubuntu.com/ubuntu/ quantal/universe amd64 Packages
100 /var/lib/dpkg/status
With source file named warning_test.c in the current working
directory, containing this:
int warning_test(int a);
int warning_test(int a)
{
int result;
if (a == 1)
result = 1;
return result;
}
... I compiled with this command line:
clang -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-
after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-
security -fno-strict-aliasing -fwrapv -g -D_GNU_SOURCE -c -o
warning_test.o warning_test.c -MMD -MP
I expected:
warning_test.c:9:9: warning: variable 'result' is uninitialized when used here [-Wuninitialized]
return result;
^~~~~~
warning_test.c:4:14: note: initialize the variable 'result' to silence this warning
int result;
^
= 0
1 warning generated.
I got a clean compile (no warnings).
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1249505/+subscriptions
More information about the foundations-bugs
mailing list