mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
C++: Tests showing problems with casts of typedefs
This commit is contained in:
@@ -265,3 +265,23 @@ int negative_zero(double dbl) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
int widening_cast1(u8 c) {
|
||||
if (c == 0) {
|
||||
if ((int)c > 0) { // BAD [NOT DETECTED]
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int widening_cast2(u8 c) {
|
||||
if (c <= 10)
|
||||
return -1;
|
||||
else if ((c >= 11) /* BAD [NOT DETECTED] */ && (c <= 47))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user