Commit Graph

7 Commits

Author SHA1 Message Date
Daniel Kroening ba34966eb5 test signed left-shift overflow for C99
The semantics of signed left shifts are contentious for the case
that a '1' is shifted into the signed bit. This tests the C99 case.
2019-01-07 17:40:31 +00:00
Daniel Kroening ae78609413 signed left-shift overflow depends on standard version
The semantics of signed left shifts are contentious for the case
that a '1' is shifted into the signed bit.
Assuming 32-bit integers, 1<<31 is implementation-defined
in ANSI C and C++98, but is explicitly undefined by C99,
C11 and C++11.
2019-01-07 11:20:04 +00:00
Daniel Kroening 3be9b5efc5 implement criteria for shl overflow in goto_check
The current implementation generates an overflow-shl predicate, which is
then interpreted by the solver APIs.  This has the disadvantage that the
predicate has semantics that are both complicated and highly
language-dependent, which is not a good fit for a solver.

The new implementation defines the meaning of signed left shift overflows in
goto-check, similar as it is already done for division and unary minus.

This is covered by an existing test:
regression/cbmc/Overflow_Leftshift1/test.desc
2019-01-04 18:43:57 +00:00
Daniel Kroening 052a8d329a improve test for signed left-shift overflows 2019-01-04 18:43:57 +00:00
Daniel Kroening 73c33841b7 results now include line number 2018-11-05 12:35:55 +00:00
Chris Smowton 3b00bdc085 Fix tests with missing EXIT or SIGNAL tests
Some tests had previously been passing despite actually causing a crash, due
to the required output being too loosely specified. This ensures the bare minimum:
that every test has an expected EXIT code and SIGNAL result.

The codes suggested were taken from the test's current output, and only applied for
CORE tests, but hand inspection suggests these choices are reasonable.
2018-03-23 11:37:53 +00:00
Michael Tautschnig 6bb387237b Check for overflow on left shift of signed ints
This is undefined behaviour according to 6.5.7 paragraph 4 in C11.
2017-10-26 16:20:25 +01:00