https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115005

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Folding statement: _336 = cmd_8bits[numbits_181];
Folded into: _336 = cmd_8bits[4294967295];


Which comes from:

                uint32 d = get_bits(in, numbits+1, &bb);

                if (d >= cmd_8bits[numbits]) {

get_bits:
static uint32 get_bits(HIO_HANDLE *f, int n, struct bit_buffer *bb)
{
        uint32 bits;

        if (n == 0) {
                return 0;
        }

There is a jump threading there handling n==0 (aka numbits==-1u) and that is
causing the warning. Now if I understand it numbits can't be more than 128 (or
even 16 in the 16bit case).

Adding `if (numbits >= 128) __builtin_unreachable();` right before the git_bits
gets rid of the warning and seems like would produce better code.

The reason why using smaller types works is well (numbits+1) can never be 0.

Reply via email to