http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52283
Bug #: 52283
Summary: "error: case label does not reduce to an integer
constant" for constant folded cast expr
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
extern int u;
void b (int c)
{
switch (c)
{
case (int) ( 2 | ( (4 < 8 ) ? 8 : u ) ) :
break;
}
}
fails with
i.c:8:5: error: case label does not reduce to an integer constant
since GCC 4.6.2.
While is is legitimately a user error with respect to the standard, this brings
legacy issue for code that used to build with GCC 4.5. Note that GCC is usually
permissive with reduced integer constant use in case label, see PR39613.
This change seems to have appeared with the removal of the lines in
c-common.c:check_case_value
/* ??? Can we ever get nops here for a valid case value? We
shouldn't for C. */
STRIP_TYPE_NOPS (value);
so the check for INTEGER_CST now fails and fallthu into the error.