http://llvm.org/bugs/show_bug.cgi?id=16868
Bug ID: 16868
Summary: warn on conditions that are too late to check for
undefined behaviour
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Examples:
bool test(int *p) {
int i = *p;
if (!p)
return false;
// ... continue using i
}
We should warn on the condition, because if the condition is ever true then
undefined behaviour must have already occurred. (Similarly on 'p' and the
condition being false.)
bool test2(int idx) {
char arr[100];
arr[idx] = '\0';
if (idx < 0 || idx >= 100) // either of these alone should also suffice to
warn
return false;
// ...
}
Examples putting the overflow inside the condition expression:
bool test3(int x) {
if ((x+1) < x)
...
bool test4(int x, int y) {
if (x != (x*y)/y)
...
--
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