[LLVMbugs] [Bug 20950] New: variable reassignment in switch not detected ?
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Sep 15 12:40:37 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=20950
Bug ID: 20950
Summary: variable reassignment in switch not detected ?
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: dcb314 at hotmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Given the following source code
void f(int n)
{
int m;
switch (n)
{
case 1: m = 2;
case 2: m = 3;
case 3: m = 4;
case 4: m = 5;
}
}
Here is trunk clang++:
$ ~/llvm/results/bin/clang++ -c -g -O2 -Wall jun23b.cc
$
Here is trunk gcc warning about something else:
$ ~/gcc/results/bin/g++ -c -g -O2 -Wall jun23b.cc
jun23b.cc: In function ‘void f(int)’:
jun23b.cc:4:6: warning: variable ‘m’ set but not used
[-Wunused-but-set-variable]
int m;
^
$
And here is trunk cppcheck finding the problem
$ ~/cppcheck/trunk/cppcheck --enable=all jun23b.cc
Checking jun23b.cc...
[jun23b.cc:8] -> [jun23b.cc:9]: (warning) Variable 'm' is reassigned a value
before the old one has been used. 'break;' missing?
[jun23b.cc:9] -> [jun23b.cc:10]: (warning) Variable 'm' is reassigned a value
before the old one has been used. 'break;' missing?
[jun23b.cc:10] -> [jun23b.cc:11]: (warning) Variable 'm' is reassigned a value
before the old one has been used. 'break;' missing?
$
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140915/79754bb0/attachment.html>
More information about the llvm-bugs
mailing list