|
From: | Paul Eggert |
Subject: | bug#49261: Segfault during loadup |
Date: | Wed, 14 Jul 2021 17:04:35 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
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.
[Prev in Thread] | Current Thread | [Next in Thread] |