c/201: Switch statement will not accept constant integer variable as case label
tron.thomas@sierra.com
tron.thomas@sierra.com
Thu May 11 09:26:00 GMT 2000
>Number: 201
>Category: c
>Synopsis: Switch statement will not accept constant integer variable as case label
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 11 09:26:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: tron.thomas@sierra.com
>Release: egcs-2.91.66 1990314/Linux (egcs-1.1.2 release)
>Organization:
>Environment:
Intel Pentium II 330, 64 megabytes of ram, RedHat Linux 6.0
>Description:
A switch statement will not accept a constant integer
variable as a case label
>How-To-Repeat:
Compile the following program (Bug.c) using:
gcc -g -Wall -o Bug Bug.c
int main(void)
{
const int nFOO = 1;
int nFoo = 0;
switch(nFoo){
case nFOO:
exit(1);
}
exit(0);
}
The following error occurs:
Bug.c:8: case label does not reduce to an integer constant
Expectation:
nFOO is a constant integer so it should be accepted as a
case variable
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list