On Wed, 19 Sep 2018 at 06:21, Vegard Nossum <vegard.nossum@xxxxxxxxxx> wrote: > > With the following code: > > enum foo { > BAR = 1ULL << 63, > }; > > I was seeing the following warning: > > enum.c:2:20: warning: cast truncates bits from constant value (8000000000000000 becomes 0) > > parse_enum_declaration() keeps track of the minimum and maximum values of > the enum's values and tries to find a data type that contain it. In this > case it ought to match 'unsigned long long', but it doesn't. The reason is > that ullong_ctype->bit_size == 64 and type_is_ok() will do a left shift of > 64 on the maximum/minimum values, which is undefined in C. > > My compiler (gcc 5.5.0) gives a non-zero value for (1ULL << 63) >> 64, and > the enum's underlying type becomes bad_ctype which has ->bit_size == -1, > thus failing the cast truncation test in cast_value(). Ahh, never mind, I saw you already have a patch for this when checking if my email made it to the list :-/ Vegard