[cfe-dev] C++: Reference to member in sizeof expression of another member declaration
Florian Weimer
fweimer at redhat.com
Sun May 12 01:18:52 PDT 2013
clang++ (trunk, both C++03 and C++11 modes) rejects the following program:
union u {
int a;
char b[sizeof(a)];
};
t.cpp:3:17: error: invalid use of non-static data member 'a'
char b[sizeof(a)];
^
This seems valid C++, considering this language in [expr.prim.general]:
"An id-expression that denotes a non-static data member […] can only be
used […] if that id-expression […] appears in an unevaluated operand"
--
Florian Weimer / Red Hat Product Security Team
More information about the cfe-dev
mailing list