enum class confirm {yes};
struct item
{
confirm s:4; // (1) limiting storage size required
};
int main()
{
item itm;
itm.s = confirm::yes; // (2) OK
switch (itm.s)
{
case confirm::yes: // (3) Failure, need static data cast here?
break;
}
}
produces error:
In function ‘int main()’:
error: could not convert ‘yes’ from ‘confirm’ to ‘int’
case confirm::yes:
^
while compiling with g++ but compiled fine by clang++. Why assignment marked by (2) possible but case clause marked by (3) not?
Warning about too small storage
is of offtopic
Aucun commentaire:
Enregistrer un commentaire