-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Narrowing test (not working though, but should)
- Loading branch information
Alina Weber
committed
Jan 31, 2024
1 parent
4806036
commit 4fa7042
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
19 changes: 12 additions & 7 deletions
19
tests/regression/77-lin2vareq/28-narrowing.c → ...n/77-lin2vareq/28-narrowing-on-steroids.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
// SKIP PARAM: --set ana.activated[+] lin2vareq --enable ana.int.interval | ||
// SKIP PARAM: --set ana.activated[+] lin2vareq --enable ana.int.interval --set sem.int.signed_overflow assume_none | ||
#include <assert.h> | ||
|
||
int g = 0; | ||
|
||
int main() { | ||
int a; | ||
a = a % 10; | ||
int b; | ||
int c; | ||
b = a + 1; | ||
c = a + 2; | ||
int x; | ||
|
||
for (x = 0; x < 50; x++) { | ||
g = 1; | ||
a = 1; | ||
} | ||
|
||
if (x > 50) { | ||
|
||
for (int i = 0; i <= 0; i--) { | ||
g = 57; | ||
c = 57; | ||
|
||
int y; | ||
|
||
for (y = 0; y < x; y++) { | ||
g = 42; | ||
b = 42; | ||
} | ||
} | ||
assert(1); // NOWARN (unreachable) | ||
assert(0); // NOWARN (unreachable) | ||
} | ||
assert(b + 1 == c);// SUCCESS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SKIP PARAM: --set ana.activated[+] lin2vareq --set sem.int.signed_overflow assume_none | ||
|
||
#include <stdio.h> | ||
int main() { | ||
|
||
unsigned int allbits = -255 - 25; // choose a value which is not representable in short | ||
int signedallbits = allbits; | ||
short unsignedtosigned = allbits; | ||
unsigned short unsignedtounsigned = allbits; | ||
|
||
printf("allbits: %u\n", allbits); | ||
printf("signedallbits: %d\n", signedallbits); | ||
printf("unsignedtosigned: %hd\n", unsignedtosigned); | ||
printf("unsignedtounsigned: %hu\n", unsignedtounsigned); | ||
|
||
if (unsignedtounsigned == 4294967295) { | ||
// __goblint_check(0); // NOWARN (unreachable) | ||
return (-1); | ||
} | ||
if (allbits == 4294967295 && signedallbits == -1 && unsignedtosigned == -1 && | ||
unsignedtounsigned == 65535) { | ||
// __goblint_check(1); // reachable | ||
return (-1); | ||
} | ||
// __goblint_check(0); // NOWARN (unreachable) | ||
return (0); | ||
} |