enum
{
Foo,
Bar,
Baz
};
enum NamedEnum
{
NamedFoo,
NamedBar,
NamedBaz
};
struct Foo
{
int i;
};
struct NamedFoo
{
int i;
};
int main()
{
Foo f;
NamedFoo nf;
f.i = 3; // #1
nf.i = 4; // #2
}
Albeit arguably bad practice, this is legal C++ code. The Foo and NamedFoo structures should hide the enum values with the same name. Surprisingly, VA X handles it differently depending on whether the enum type the value belongs to is named or not. On #1, after typing the '.', I get a suggestion list containing only the i, as I expect. But in #2, I get a list containing all other enum values belonging to NamedEnum, and no i.
The actual code I used to discover this bug was (in my opinion) not so bad practice. I was using a nested class:
struct MyStruct
{
struct NamedFoo
{
int i;
};
void f(NamedFoo * f);
{
f->i = 3; // #3
}
void g(NamedFoo * f);
};
void MyStruct::g(MyStruct::NamedFoo * f)
{
NamedFoo * f2 = f;
f->i = 3; // #4
f2->i = 5; // #5
}
In #3 and #5, it shows the enum list as before. #4, however, is correct, so it seems that when you explicitely define the scope (MyStruct::NamedFoo instead of just NamedFoo) VA X actually understands that you're using the class type, and not the enum value.
I would like to suggest that listboxes always list the class elements instead of other enum values, as it is quite pointless to do a memberselection on an enum value.