Skip to content

Conversation

@Wesmania
Copy link

SET macro is used to set bits of unsigned long, but the shifted numeric
constants are ints, left-shifting too much causes undefined behaviour.
Cast constants to target type before shifting.

Signed-off-by: Igor Kotrasinski ikotrasinsk@gmail.com

SET macro is used to set bits of unsigned long, but the shifted numeric
constants are ints, left-shifting too much causes undefined behaviour.
Cast constants to target type before shifting.

Signed-off-by: Igor Kotrasinski <ikotrasinsk@gmail.com>
@thkala
Copy link
Owner

thkala commented May 14, 2017

(Disclaimer: I did not have the time to really look into this, so beware...)

IIRC typeof() is a GNU compiler extension. Rather than using something like that, wouldn't it be simpler to just use 1U to force the constants to unsigned?

How did this problem manifest, anyway?

insert_rant_about_10yo_C_code_and_how_I_d_have_done_it_differently_now()

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.

2 participants