Skip to content

Fix undefined behavior from signed left-shift in MSVC-MingW port#1411

Merged
rawalexe merged 1 commit intomainfrom
shiftingFix
May 6, 2026
Merged

Fix undefined behavior from signed left-shift in MSVC-MingW port#1411
rawalexe merged 1 commit intomainfrom
shiftingFix

Conversation

@rawalexe
Copy link
Copy Markdown
Member

@rawalexe rawalexe commented May 6, 2026

Replace ( 1 << n ) with ( 1UL << n ) in all left-shift expressions in portable/MSVC-MingW/port.c. Shifting a signed int by >= 31 is undefined behavior per ISO C11 §6.5.7.

Description

Test Steps

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Replace `( 1 << n )` with `( 1UL << n )` in all left-shift expressions
in portable/MSVC-MingW/port.c. Shifting a signed int by >= 31 is
undefined behavior per ISO C11 §6.5.7.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@rawalexe rawalexe merged commit a8c9d35 into main May 6, 2026
34 checks passed
@aggarg aggarg deleted the shiftingFix branch May 7, 2026 05:24
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.

3 participants