http://llvm.org/bugs/show_bug.cgi?id=9143
Summary: -Wuninitialized suggests `= 0` for enums
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
hummer:src thakis$ cat test.cc
enum A {
A_a, A_b
};
A f() {
A a;
return a;
}
hummer:src thakis$ ~/src/llvm-svn/Release+Asserts/bin/clang -c test.cc -Wall
test.cc:6:10: warning: variable 'a' is possibly uninitialized when used here
[-Wuninitialized]
return a;
^
test.cc:5:3: note: variable 'a' is declared here
A a;
^
test.cc:5:6: note: add initialization to silence this warning
A a;
^
= 0
1 warning generated.
But doing this is of course not valid:
hummer:src thakis$ cat test.cc
enum A {
A_a, A_b
};
A f() {
A a = 0;
return a;
}
hummer:src thakis$ ~/src/llvm-svn/Release+Asserts/bin/clang -c test.cc -Wall
test.cc:5:5: error: cannot initialize a variable of type 'A' with an rvalue of
type 'int'
A a = 0;
^ ~
1 error generated.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs