[Bug c/93241] [8/9/10 Regression] _Bool casts in dead branches of integer constant expressions cause undesirable warnings under -pedantic iff the dead branch contains overflow
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 14 00:15:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93241
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Joseph Myers <jsm28@gcc.gnu.org>:
https://gcc.gnu.org/g:2638a44bbe43089f9fc00251592895584314a4b2
commit r9-8131-g2638a44bbe43089f9fc00251592895584314a4b2
Author: Joseph Myers <joseph@codesourcery.com>
Date: Tue Jan 14 00:13:21 2020 +0000
Fix handling of overflow in C casts in integer constant expressions (PR
c/93241).
Bug 93241 reports a case where certain C expressions involving casts,
that would not be valid in an evaluated part of an integer constant
expression (because of e.g. involving integer overflow), are wrongly
rejected in an unevaluated part of an integer constant expression even
though all the operands and operations are ones that are valid in that
context. This is a rejects-valid regression in GCC 4.5 and later
relative to 4.4 (for some testcases; the one in the bug uses
_Static_assert which isn't supported in those older releases).
The rule in the C front end is that an expression with those
properties (valid in an unevaluated part of an integer constant
expression but not an evaluated part) must be represented either as an
INTEGER_CST with TREE_OVERFLOW set or as a C_MAYBE_CONST_EXPR with
C_MAYBE_CONST_EXPR_INT_OPERANDS set. This patch fixes build_c_cast to
check for that case and call note_integer_operands as needed.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
PR c/93241
gcc/c:
* c-typeck.c (build_c_cast): Check for expressions with integer
operands that can occur in an unevaluated part of an integer
constant expression and call note_integer_operands as needed.
gcc/testsuite:
* gcc.dg/c11-static-assert-10.c, gcc.dg/c99-const-expr-15.c: New
tests.
(cherry picked from commit 3d77686d2eddf76d3498169d0ca5653db45a8662)
More information about the Gcc-bugs
mailing list