[CPP-434] Drop the requirement that RHS not be cast to unsigned, since overflow occurs on LHS. Adjust test case.

This commit is contained in:
Ziemowit Laski
2019-10-11 17:01:16 -07:00
parent 33cd6de729
commit 5558922b31
3 changed files with 5 additions and 9 deletions

View File

@@ -25,6 +25,5 @@ where
add.getAnOperand() = va1 and
ro.getAnOperand() = va2 and
globalValueNumber(va1) = globalValueNumber(va2) and
isSignedWithoutUnsignedCast(add) and
isSignedWithoutUnsignedCast(va2)
isSignedWithoutUnsignedCast(add)
select ro, "Testing for signed overflow may produce undefined results."

View File

@@ -94,11 +94,7 @@ int checkOverflow4(unsigned int ioff, C c) {
return 1;
}
#define AV_INPUT_BUFFER_PADDING_SIZE 64
int overflow12(int codecdata_length) {
if(codecdata_length + AV_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length) { // GOOD
return -1;
}
return 1;
int overflow12(int n) {
// not deleted by gcc or clang
return (n + 32 <= (unsigned)n? -1: 1); // BAD
}

View File

@@ -1,3 +1,4 @@
| SignedOverflowCheck.cpp:8:12:8:22 | ... < ... | Testing for signed overflow may produce undefined results. |
| SignedOverflowCheck.cpp:18:12:18:26 | ... < ... | Testing for signed overflow may produce undefined results. |
| SignedOverflowCheck.cpp:35:9:35:23 | ... < ... | Testing for signed overflow may produce undefined results. |
| SignedOverflowCheck.cpp:99:10:99:30 | ... <= ... | Testing for signed overflow may produce undefined results. |