[Bug c++/35205] New: Structure enum wrongly interpreted as a variable in switch case.
y-iguchi at ak dot jp dot nec dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 15 00:29:00 GMT 2008
gcc 4.1.2 compiler issues an error that 'a.x' is not a constant while I expect
'a.x' is a constant.
$ cat test.c
#include <stdio.h>
struct s{
int i;
enum {x};
}a;
int main(void)
{
switch(1){
case a.x: ;
}
return 0;
}
$ g++ test.c
test.c: In function 'int main()':
test.c:11: error: 'a' cannot appear in a constant-expression
test.c:11: error: `.' cannot appear in a constant-expression
$ g++ --version
g++ (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
--
Summary: Structure enum wrongly interpreted as a variable in
switch case.
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: y-iguchi at ak dot jp dot nec dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35205
More information about the Gcc-bugs
mailing list