mirror of
https://github.com/github/codeql.git
synced 2026-05-03 12:45:27 +02:00
C++: Test for UnsignedGEZero with templates
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
template<typename T>
|
||||
bool sometimesPointless(T param) {
|
||||
return param >= 0; // GOOD (FALSE POSITIVE: hypothetical instantiations are okay)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool alwaysPointless(T param) {
|
||||
unsigned int local = param;
|
||||
return local >= 0; // BAD (in all instantiations)
|
||||
}
|
||||
|
||||
static int caller(int i) {
|
||||
return
|
||||
sometimesPointless<unsigned int>(i) ||
|
||||
alwaysPointless<unsigned int>(i) ||
|
||||
alwaysPointless<int>(i);
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
| Templates.cpp:3:10:3:19 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
| Templates.cpp:9:10:9:19 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
| Templates.cpp:9:10:9:19 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
| Templates.cpp:9:10:9:19 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
| UnsignedGEZero.c:40:6:40:12 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
| UnsignedGEZero.c:48:6:48:15 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
| UnsignedGEZero.c:54:6:54:12 | ... >= ... | Pointless comparison of unsigned value to zero. |
|
||||
|
||||
Reference in New Issue
Block a user