[cfe-dev] C++: Reference to member in sizeof expression of another member declaration

Richard Smith richard at metafoo.co.uk
Sun May 12 16:41:37 PDT 2013

On Sun, May 12, 2013 at 1:18 AM, Florian Weimer <fweimer at redhat.com> wrote:

> 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"

Trunk accepts this for me in C++11, and rejects in C++98, which IIRC is
correct behavior.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130512/651e5f0e/attachment.html>

More information about the cfe-dev mailing list