Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix undefined behavior #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix undefined behavior #367

wants to merge 1 commit into from

Conversation

pitust
Copy link

@pitust pitust commented Nov 16, 2024

The current implementation of the M4 macro leads to a signed integer overflow error, which is undefined behavior:

The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has
an unsigned type, the value of the result is E1 × 2E2, wrapped around. If E1 has a signed type and
nonnegative value, and E1 × 2^E2 is representable in the result type, then that is the resulting value;
otherwise, the behavior is undefined

(emphasis added, N3219 6.5.8.5)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant