Robert Haas <robertmh...@gmail.com> writes:
> On Fri, Jun 5, 2020 at 8:19 PM Andres Freund <and...@anarazel.de> wrote:
>> Randomly noticed while looking at the code:
>>      uint64          flagbit = UINT64CONST(1) << (uint64) type;
>> 
>> that shouldn't be 64bit, right?

> I'm going to admit ignorance here. What's the proper coding rule?

The shift distance can't exceed 64, so there's no need for it to be
wider than int.  "type" is an enum, so explicitly casting it to an
integral type seems like good practice, but int is sufficient.

ISTR older compilers insisting that the shift distance not be
wider than int.  But C99 doesn't seem to require that -- it only
restricts the value of the right operand.

                        regards, tom lane


Reply via email to