forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mimic GCC/Clang simplification behaviour when type checking ?:
Neither GCC nor Clang simplify expressions involving symbols even when the result would always be 0, which our simplifier figure out. Fixes: diffblue#7927
- Loading branch information
1 parent
b40e6c7
commit 6f82cc7
Showing
3 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
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,23 @@ | ||
int main() | ||
{ | ||
long long i; | ||
#ifndef _MSC_VER | ||
_Static_assert(sizeof(int) == sizeof(*(1 ? ((void *)(0ll)) : (int *)1)), ""); | ||
// We are able to simplify all of the expressions involving i below to 0, but | ||
// GCC and Clang don't do so. Hence, the static asserts pass for those | ||
// compilers. | ||
_Static_assert( | ||
sizeof(int) != sizeof(*(1 ? ((void *)(i * 0)) : (int *)1)), ""); | ||
_Static_assert( | ||
sizeof(int) != sizeof(*(1 ? ((void *)(i - i)) : (int *)1)), ""); | ||
_Static_assert( | ||
sizeof(int) != sizeof(*(1 ? ((void *)(i ? 0ll : 0ll)) : (int *)1)), ""); | ||
_Static_assert( | ||
sizeof(int) != sizeof(*(1 ? ((void *)(0 ? i : 0ll)) : (int *)1)), ""); | ||
#else | ||
static_assert(sizeof(int) == sizeof(*(1 ? ((void *)(0)) : (int *)1)), ""); | ||
// Visual Studio rejects this as "illegal indirection" | ||
// static_assert( | ||
// sizeof(int) == sizeof(*(1 ? ((void *)(i * 0)) : (int *)1)), ""); | ||
#endif | ||
} |
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,8 @@ | ||
CORE | ||
main.c | ||
|
||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring | ||
^CONVERSION ERROR$ |
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