[cfe-commits] Sizeof for non-static class members

Eli Friedman eli.friedman at gmail.com
Thu Feb 2 13:52:11 PST 2012


On Wed, Feb 1, 2012 at 10:55 PM, Michael Price
<michael.b.price.dev at gmail.com> wrote:
> Attached is a patch that adds tests for the C++11 feature that allows
> non-static class members to be used in the parameter of sizeof() without
> needing an instance, i.e.
>
> struct S { int m; }
> sizeof(S::m);
>
> It seems that code that implements this feature was committed in late 2010,
> but there was never any update to the status page.  If we think that these
> tests confirm that the feature is complete, I can submit a different patch
> to update the cxx_status.html page (or someone else can update it if they
> care to backtrace availability to a "released" version of clang).
>
> Questions are welcome.

We already have some tests in
test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp .  That said,
there is still one known issue: the following still doesn't work:

struct X { char a; };
struct Y { int f() { return sizeof(X::a); } };

-Eli




More information about the cfe-commits mailing list