Hi coreboot fellows,

another patch that fixes a `1 << 31` to `1UL << 31` [1] reminded me that
some people objected to such changes. I'm not sure if we ever draw a
conclusion on the matter.

`1 << 31` is undefined behavior because the `1` can (and thus will) be
represented as a (signed) `int` which is limited by 2^31-1 for all our
targets. But we know very well that GCC (and I assume Clang too) do the
right thing: Produce a value that when casted to an `unsigned int` is
converted to 2^31.

So, it's wrong but not broken ;) and any suffix to the `1` makes it a
bit harder to read.

What do you think? Should we allow such changes? Should we normalize
on any style?

If we want to make it defined behavior, my personal preference would be
`1u << 31`. Lower case because it's more distinct from the number part,
and we actually don't need a long (that might even hide actual errors
if we want a 32-bit limited value).

Cheers,
Nico

PS. Happy new year btw. :D

[1] https://review.coreboot.org/c/coreboot/+/49076
_______________________________________________
coreboot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to