This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52283] New: "error: case label does not reduce to an integer constant" for constant folded cast expr
- From: "chrbr at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Feb 2012 16:29:55 +0000
- Subject: [Bug c/52283] New: "error: case label does not reduce to an integer constant" for constant folded cast expr
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: chrbr@gcc.gnu.org
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.