https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93241
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-8 branch has been updated by Joseph Myers <js...@gcc.gnu.org>: https://gcc.gnu.org/g:a2a2a06cafff858f3211a53a6ecc215f5b296565 commit r8-9933-ga2a2a06cafff858f3211a53a6ecc215f5b296565 Author: Joseph Myers <jos...@codesourcery.com> Date: Tue Jan 14 16:53:26 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)