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).

Reply via email to