Skip to content

Commit 4e375cd

Browse files
Add tests for overflows
There is an interaction between type promotion and overflow detection. In the case of compound assignments type promotion is broken.
1 parent a869788 commit 4e375cd

File tree

6 files changed

+55
-0
lines changed

6 files changed

+55
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void main()
2+
{
3+
signed char i, j;
4+
i = j;
5+
i += 1;
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--signed-overflow-check
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[.*\] .* arithmetic overflow on signed \+ in .*: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void main()
2+
{
3+
signed char i, j;
4+
i = j;
5+
i += 1;
6+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
KNOWNBUG
2+
main.c
3+
--signed-overflow-check --conversion-check
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[.*\] .* arithmetic overflow on signed \+ in .*: SUCCESS
7+
^\[.*\] .* arithmetic overflow on signed type conversion in .*: FAILURE$
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
11+
--
12+
The addition is done in signed int; hence, the overflow is only detected
13+
on conversion.
14+
15+
See #4208.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
void main()
2+
{
3+
signed char i, j;
4+
i = j;
5+
i = i + 1;
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
main.c
3+
--signed-overflow-check --conversion-check
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[.*\] .* arithmetic overflow on signed \+ in .*: SUCCESS
7+
^\[.*\] .* arithmetic overflow on signed type conversion in .*: FAILURE$
8+
^VERIFICATION FAILED$
9+
--
10+
^warning: ignoring
11+
--
12+
The addition is done in signed int; hence, the overflow is only detected
13+
on conversion.

0 commit comments

Comments
 (0)