Search code examples
c++c++11list-initialization

Can list initialization not be used for private members?


struct A
{
private:
    int a, b, c;
};

int main()
{
    A a1{};
    A a2 = {};

    return 0;
}

The code was compiled by VC++ 2012 (with the latest update "Nov 2012 CTP").

I expect a1 and a2 are zero-initialized, but not. a1 and a2 are not initialized.

Why?


Solution

  • You mean Microsoft's Community Tech Preview compiler, which they aren't even confident enough in to call it a beta, has bugs in it? ;)

    This is a bug; it should behave as you expect. Please report it as such.