C++: Test showing FP with -fno-strict-overflow

This commit is contained in:
Jonas Jensen
2019-11-13 11:58:27 +01:00
parent 8ed991759c
commit 463bf964a9
2 changed files with 7 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
| no_strict_overflow.c:5:9:5:21 | ... < ... | Range check relying on pointer overflow. |
| test.cpp:6:12:6:33 | ... < ... | Range check relying on pointer overflow. |
| test.cpp:33:9:33:21 | ... < ... | Range check relying on pointer overflow. |

View File

@@ -0,0 +1,6 @@
// semmle-extractor-options: -fno-strict-overflow
int not_in_range_nostrict(int *ptr, int *ptr_end, unsigned int a) {
return ptr + a < ptr_end || // GOOD (for the purpose of this test)
ptr + a < ptr; // GOOD (due to compiler options) [FALSE POSITIVE]
}