Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 683
xmllmx Avatar asked Nov 16 '12 19:11

xmllmx


1 Answers

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.

like image 91
Nicol Bolas Avatar answered Oct 16 '22 15:10

Nicol Bolas