[Bug c/68971] -Woverflow false alarm in code unreachable after __builtin_mul_overflow

eggert at gnu dot org gcc-bugzilla@gcc.gnu.org
Fri Dec 18 08:37:00 GMT 2015


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

--- Comment #6 from Paul Eggert <eggert at gnu dot org> ---
(In reply to Martin Sebor from comment #5)
> This is a valid constant expression

I'm aware of the distinction between constant and other expressions. I'm trying
to give the ordinary user's viewpoint, not the viewpoint of a language
standards nerd. From the ordinary user's viewpoint GCC is busted here because
it is crying wolf. There are tons of other places where GCC could cry wolf
while following the letter of the standard, but GCC doesn't do that because in
practice crying wolf is counterproductive.

> since __builtin_mul_overflow has already computed the product it
> seems that the result should be used rather than computed again using plain
> multiplication.

It's a test program, and it's doing things twice in order to test them for
consistency. You're right, most likely this particular combination wouldn't
occur except in test programs. So it could be that the use of -Wno-overflow can
be limited to test programs, if we're lucky. Still, it'd be better if GCC were
fixed to not cry wolf in situations like these.


More information about the Gcc-bugs mailing list