This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Thu, 17 Dec 2015, msebor at gcc dot gnu.org wrote:

> Paul, the way I prefer to look at it is that the C standard says that constant
> expressions are evaluated during translation and when the evaluation overflows
> the behavior is undefined.  The program is incorrect and the warning helps find
> the bug.  That GCC happens to handle it gracefully is a bonus.

There are several issues with the standard specification of constant 
expressions, but my understanding is that all the requirements on constant 
expressions apply where the syntax specifies that there is a constant 
expression, not where some expression happens to have operands that are 
constants but is used in a context not requiring a constant expression.  
Thus, overflow in an expression of constants, where a constant expression 
is not required, produces a warning rather than a pedwarn.  Furthermore, 
it seems clear that where a constant expression *is* required, unevaluated 
subexpressions may contain overflows just as they may contain division by 
zero (footnote 118).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]