Compilation error when using empty list initialization constructor in C++17
18
2
I ran into a weird problem when trying to move to C++17. The problem is that something (and I'm not sure what) changed in C++17 that made list-initialization work differently in the case of a default constructor. I tried to search https://en.cppreference.com/w/cpp/language/list_initialization for more info, but I didn't find anything that looks relevant. Does someone know the reason the code below compiles in C++14 but not in C++17 when calling B{} instead of B() ? (I tried it in both gcc 8.2 and 7.3 and icc 19) struct A{ protected: A() {} }; struct B : public A {}; B f(){ return B(); //compilation OK //return B{}; //compilation error }
c++ c++17 list-initialization
share ...