C++: Support GCC flags making ptr overflow defined

This commit is contained in:
Jonas Jensen
2019-11-13 11:59:44 +01:00
parent 463bf964a9
commit d2009c53dc
2 changed files with 6 additions and 2 deletions

View File

@@ -25,6 +25,11 @@ where
not exists(MacroInvocation mi | not exists(MacroInvocation mi |
mi.getAnAffectedElement() = add and mi.getAnAffectedElement() = add and
not mi.getMacroName().toLowerCase().matches("%assert%") not mi.getMacroName().toLowerCase().matches("%assert%")
) and
// There must be a compilation of this file without a flag that makes pointer
// overflow well defined.
exists(Compilation c | c.getAFileCompiled() = ro.getFile() |
not c.getAnArgument() = "-fwrapv-pointer" and
not c.getAnArgument() = "-fno-strict-overflow"
) )
// TODO: Add a check for -fno-strict-overflow and -fwrapv-pointer
select ro, "Range check relying on pointer overflow." select ro, "Range check relying on pointer overflow."

View File

@@ -1,3 +1,2 @@
| 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:6:12:6:33 | ... < ... | Range check relying on pointer overflow. |
| test.cpp:33:9:33:21 | ... < ... | Range check relying on pointer overflow. | | test.cpp:33:9:33:21 | ... < ... | Range check relying on pointer overflow. |