mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
It still runs on uninstantiated templates because its underlying libraries do. It's not clear whether that leads to other false positives, but that's independent of the change I'm making here.
18 lines
410 B
C++
18 lines
410 B
C++
template<typename T>
|
|
bool sometimesPointless(T param) {
|
|
return param <= 0xFFFF; // GOOD (hypothetical instantiations are okay)
|
|
}
|
|
|
|
template<typename T>
|
|
bool alwaysPointless(T param) {
|
|
short local = param;
|
|
return local <= 0xFFFF; // BAD (in all instantiations)
|
|
}
|
|
|
|
static int caller(int i) {
|
|
return
|
|
sometimesPointless<short>(i) ||
|
|
alwaysPointless<short>(i) ||
|
|
alwaysPointless<int>(i);
|
|
}
|