gcc 4 pickiness on enums

An interesting problem which arises from anonymous enums, templates and gcc 4.0.0 which gives a dread error:
‘<anonymous enum>’ is/uses anonymous type’ on the following code on the i == unnamedA line. Workaround in trivial, but it’s behaviour which I found surprising if apparently legal.

class Any;
template< class C > bool operator == ( const Any & rAny, const C & value );
enum named {namedA=0};
enum {unnamedA=0};
int main(void)
{
	int i=100;
	if (i == namedA)
		return 1;
	if (i == unnamedA)
		return 1;
	return 0;
}

Comments are closed.