Skip to content

Commit 027f22d

Browse files
committed
C++: Test that range analysis ignores references
1 parent a3a3423 commit 027f22d

File tree

1 file changed

+22
-0
lines changed
  • cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis

1 file changed

+22
-0
lines changed

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,25 @@ void use_after_cast(unsigned char c)
7878
}
7979
c_times_2;
8080
}
81+
82+
int ref_to_number(int &i, const int &ci, int &aliased) {
83+
int &alias = aliased; // no range analysis for either of the two aliased variables
84+
85+
if (i >= 2)
86+
return i; // BUG: lower bound should be 2
87+
88+
if (ci >= 2)
89+
return ci; // BUG: lower bound should be 2
90+
91+
if (aliased >= 2)
92+
return aliased;
93+
94+
if (alias >= 2)
95+
return alias;
96+
97+
for (; i <= 12345; i++) {
98+
i; // BUG: upper bound should be deduced (but subject to widening)
99+
}
100+
101+
return 0;
102+
}

0 commit comments

Comments
 (0)