Skip to content

core: Fix shift behavior on non-x86_64#1316

Open
jcpunk wants to merge 1 commit intogoogle:masterfrom
jcpunk:fix-ub-shifts
Open

core: Fix shift behavior on non-x86_64#1316
jcpunk wants to merge 1 commit intogoogle:masterfrom
jcpunk:fix-ub-shifts

Conversation

@jcpunk
Copy link
Copy Markdown
Contributor

@jcpunk jcpunk commented Mar 30, 2026

Shift left on aarch64 and others produced:
FAIL (exit code): /builddir/build/BUILD/jsonnet-0.22.0-build/jsonnet-0.22.0/redhat-linux-build/jsonnet --ext-str var1=test --ext-code var2='{x:1,y:2}' error.integer_left_shift_runtime.jsonnet This run's output:
-9223372036854775808
Actual exit code 0, expected 1

The code now has explicit size and sign handling.
Fixes: #1315

Shift left on aarch64 and others produced:
FAIL (exit code):  /builddir/build/BUILD/jsonnet-0.22.0-build/jsonnet-0.22.0/redhat-linux-build/jsonnet  --ext-str var1=test --ext-code var2='{x:1,y:2}'  error.integer_left_shift_runtime.jsonnet
This run's output:
-9223372036854775808
Actual exit code 0, expected 1

The code now has explicit size and sign handling.
Fixes: google#1315

Signed-off-by: Pat Riehecky <riehecky@fnal.gov>
@johnbartholomew
Copy link
Copy Markdown
Collaborator

Sigh. Getting this right in C++ remains tricky, apparently, and I wasn't careful enough. Thanks for the fix!

@jcpunk
Copy link
Copy Markdown
Contributor Author

jcpunk commented Mar 30, 2026

Running a test build at : https://koji.fedoraproject.org/koji/taskinfo?taskID=143858182

@jcpunk
Copy link
Copy Markdown
Contributor Author

jcpunk commented Mar 30, 2026

Test build completed and passed unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect handling of left shift overflow on non-x86_64 (returns value instead of runtime error)

2 participants