Subject: Re: bug#49261: Segfault during loadup

From: Paul Eggert <[email-masked]>
Date: Wed, 14 Jul 2021 17:04:35 -0500

On 7/14/21 2:42 AM, Andreas Schwab wrote:
> On Jul 13 2021, Paul Eggert wrote:
>
>> However, there is no overflow here:
>>
>> unsigned a = -1, b = INT_MIN, c = LLONG_MAX;
>>
>> and these declarations have well-defined behavior in C,
> This is a bogus argument.

It's not bogus. I quoted the GCC documentation and noted that GCC's 
behavior does not match its documentation. At the very least -- even if 
you like GCC's behavior, which I don't -- the documentation should match 
the behavior.

> assinging a wider constant to a narrow object,
> losing bits, is likely hiding a bug.

If that's what you think -Woverflow should do, then GCC doesn't do that 
either. For example:

unsigned char a = -1, b = 255;

This generates no warning with -Woverflow, even though A's 
initialization assigns a wider constant to a narrow object, losing bits.

Without looking at GCC's source code, it's not clear what -Woverflow 
actually does. It is a bit of a mess. Certainly -Woverflow does not do 
what it's documented to do.