Frama-C Bug Tracking System - Frama-C
View Issue Details
0002354Frama-CPlug-in > RTEpublic2018-02-03 12:152018-11-30 10:07
xleroy 
signoles 
normalminorhave not tried
closedfixed 
Frama-C 16-Sulfur 
Frama-C 18-Argon 
0002354: RTE assertion for signed right shift is wrong
Consider:

/*@ ensures \result == arg >> 2; */

int toto(int arg) { return arg >> 2; }

"frama-c -wp -wp-rte" fails to verify this rather tautological spec because the RTE pass inserts the assertion

  /*@ assert rte: shift: 0 ≤ arg; */

I think this is an incorrect reading of the ISO C 90 and C 99 specs: right-shift of a signed integer expression that has a negative value is implementation-defined, but is not an undefined behavior. (See ISO C 99 section 6.5.7 item 5.)

I would suggest that WP and RTE accept the spec above, so that I can actually reason about the right shift, probably by adding axioms specifying how right shifts of negative numbers work on the platforms I am (and everyone is) interested in.
No tags attached.
Issue History
2018-02-03 12:15xleroyNew Issue
2018-02-03 12:15xleroyStatusnew => assigned
2018-02-03 12:15xleroyAssigned To => signoles
2018-10-15 17:17signolesNote Added: 0006664
2018-10-15 17:17signolesStatusassigned => resolved
2018-10-15 17:17signolesResolutionopen => fixed
2018-11-30 10:07signolesFixed in Version => Frama-C 18-Argon
2018-11-30 10:07signolesStatusresolved => closed

Notes
(0006664)
signoles   
2018-10-15 17:17   
A new kernel option (-warn-right-shift-negative) has been introduced for controlling this behaviour. It is deactivated by default (while -warn-left-shift-negative is activated by default), hence no assertion is now emitted by default on your example.

This option is supported by plug-ins Eva and RTE. The assertions generated by RTE impact plug-ins E-ACSL and WP.