Shift right on signed integers as arithmetic shift (-logical-signed-right-shift
)
Specify that your compiler implements right shifts on signed integers as arithmetic shifts
Since R2023b
Description
The option with this name is available only in the Polyspace Platform (Polyspace Test) user interface. For the equivalent option in the standard Polyspace® user interface, see Signed right shift (-logical-signed-right-shift)
.
Specify that your compiler implements right shifts on signed integers as arithmetic shifts (sign bit preserved). Compilers typically implements right shift on signed integers as arithmetic shift instead of logical shift.
If you clear this check box, Polyspace assumes that your compiler performs logical right shifts on signed integers.
This option is equivalent to the option Signed right shift (-logical-signed-right-shift)
.
Set Option
User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Build tab on the Target & Compiler node.
Command line: Use the option
-logical-signed-right-shift
. See Command-Line Information.
Why Use This Option
The C99 Standard (sec 6.5.7) states that for a right-shift operation x1>>x2
, if x1
is signed and has negative values, the behavior is implementation-defined. Different compilers choose between arithmetic and logical shift. Use this option to emulate your compiler.
Settings
- On (default)
This option indicates that the right shift is arithmetic. That is, during the shift, the sign bit remains:
(-4) >> 1 = -2 (-7) >> 1 = -4 7 >> 1 = 3
- Off
This option indicates that the right shift is logical. That is, 0 replaces the sign bit:
(-4) >> 1 = (-4U) >> 1 = 2147483646 (-7) >> 1 = (-7U) >> 1 = 2147483644 7 >> 1 = 3
Command-Line Information
When using the command line, arithmetic is the default computation mode. When this option is set, logical computation is performed.
Parameter:
-logical-signed-right-shift |
Default: Arithmetic signed right shifts |
Example (Bug Finder):
polyspace-bug-finder -logical-signed-right-shift |
Example (Code Prover):
polyspace-code-prover -logical-signed-right-shift |
Example (Bug Finder Server):
polyspace-bug-finder-server -logical-signed-right-shift |
Example (Code Prover Server):
polyspace-code-prover-server -logical-signed-right-shift |
Version History
Introduced in R2023b