Shift right on signed integers as arithmetic shift (-logical-signed-right-shift)
R2026bSpecify that your compiler implements right shifts on signed integers as arithmetic shifts
Since R2023b
Description
Specify that your compiler implements right shifts on signed integers as arithmetic shifts (sign bit preserved). Compilers typically implement right shifts 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
Set the option using one of these methods:
Polyspace Platform user interface (desktop products only): In your project configuration, on the Build tab, select the Target and Compiler node and then select this option.
Command line and options file: Use the option
-logical-signed-right-shift. See Command-Line Information.Python® API: Set the
ArithmeticSignedIntegerRightShiftproperty in the build configuration. Seepolyspace.project.BuildConfiguration(Polyspace Test).TOML configuration file (
.toml.pscfg) — Use the keyArithmeticSignedIntegerRightShift. For example:ArithmeticSignedIntegerRightShift = true
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