under gcc-4.5, it prints 0, under gcc-4.6, it prints 1.
#include <iostream>
enum VenueId: char {};
int
main (int argc, char ** argv)
{
VenueId v = (VenueId)'P';
std::cout << (v=='P') << std::endl;
return 0;
}
As per standard, VenuedId
has char
type as underlying type, so v
should contain char 'P'
, v == 'P'
should yield true.
§ 7.2 Enumeration declarations
Each enumeration defines a type that is different from all other types. Each enumeration also has an underlying type. The underlying type can be explicitly specified using enum-base; if not explicitly specified, the underlying type of a scoped enumeration type is int. In these cases, the underlying type is said to be fixed. Following the closing brace of an num-specifier, each enumerator has the type of its enumeration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With