[LLVMbugs] [Bug 14820] New: warn on invalid assignment
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jan 6 14:50:58 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=14820
Bug #: 14820
Summary: warn on invalid assignment
Product: clang
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: nicholas at mxc.ca
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
I think this C code has undefined behaviour:
enum E { X, Y, Z };
void test() {
enum E e = -1;
}
and we don't currently warn on that. If you later query e == -1 we warn on
*that*, but that's somewhat redundant as UB has already occurred.
We have a similar problem in C++, but at least it's safer:
enum E { X, Y, Z };
void test() {
E e = (E)-1;
}
doesn't warn. We should also warn on 'return (E)-1;' and similar.
--
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.
More information about the llvm-bugs
mailing list