mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
C++: Test that range analysis ignores references
This commit is contained in:
@@ -78,3 +78,25 @@ void use_after_cast(unsigned char c)
|
||||
}
|
||||
c_times_2;
|
||||
}
|
||||
|
||||
int ref_to_number(int &i, const int &ci, int &aliased) {
|
||||
int &alias = aliased; // no range analysis for either of the two aliased variables
|
||||
|
||||
if (i >= 2)
|
||||
return i; // BUG: lower bound should be 2
|
||||
|
||||
if (ci >= 2)
|
||||
return ci; // BUG: lower bound should be 2
|
||||
|
||||
if (aliased >= 2)
|
||||
return aliased;
|
||||
|
||||
if (alias >= 2)
|
||||
return alias;
|
||||
|
||||
for (; i <= 12345; i++) {
|
||||
i; // BUG: upper bound should be deduced (but subject to widening)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user