Skip to content

meson: do not allow bit-shift overflows - #9245

Merged
filbranden merged 1 commit into
systemd:masterfrom
keszybz:reject-overshift
Jun 9, 2018
Merged

filbranden merged 1 commit into
systemd:masterfrom
keszybz:reject-overshift

Conversation

@keszybz

@keszybz keszybz commented Jun 9, 2018

Copy link
Copy Markdown
Member

The primary motivation is to catch enum values created through a shift that is
too big:

../src/test/test-sizeof.c:26:29: error: left shift count >= width of type [-Werror=shift-count-overflow]
enum_with_shift = 1 << 32,
^~
cc1: some warnings being treated as errors

The compiler will now reject those.

This is an alternative to #9224.

The primary motivation is to catch enum values created through a shift that is
too big:

../src/test/test-sizeof.c:26:29: error: left shift count >= width of type [-Werror=shift-count-overflow]
         enum_with_shift = 1 << 32,
                             ^~
cc1: some warnings being treated as errors

The compiler will now reject those.

This is an alternative to systemd#9224.
@keszybz keszybz added the meson label Jun 9, 2018

@filbranden filbranden left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

This is an alternative to #9224.

But no reason why that one shouldn't be pushed either... Fine to have both around.

@filbranden
filbranden merged commit b05ecb8 into systemd:master Jun 9, 2018
@keszybz
keszybz deleted the reject-overshift branch June 9, 2018 21:02
@keszybz

keszybz commented Jun 9, 2018

Copy link
Copy Markdown
Member Author

It's an alternative in the sense that it makes the other partially obsolete — there is not need to worry about specifying a wide type because the compiler will warn if the type is not wide enough.

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

Labels

Development

Successfully merging this pull request may close these issues.

2 participants