The C++17 rules for aggregate initialization changed to disallow types with explicit constructors [dcl.init.aggr]p1. This patch implements that new rule.
Details
Diff Detail
Event Timeline
Please also add a test to test/CXX/drs/dr15xx.cpp for core issue 1518, which this paper was resolving.
lib/AST/DeclCXX.cpp | ||
---|---|---|
564 | Do we correctly handle the "or inherited" part? I'd also like to find out whether core intended for this issue to be treated as a DR or not (if so, this should apply all the way back to C++11). |
- Disallow classes with inherited constructors
- Add tests under test/CXX/drs/dr15xx.cpp
I still only implemented this change in C++1z, please let me know if you want me to backport the DR.
@rsmith ping. This is kind-of blocking making libc++'s tag types not constructible from {}.
lib/AST/DeclCXX.cpp | ||
---|---|---|
564 | According to the current issues list, this issue is in DRWP status, so this change should be applied retroactively to C++11 and C++14 as well. |
OK, I've applied the fix to C++11 and C++14. Although the inheriting-constructor part still only matters in C++1z since it requires having base classes.
I also fixed aggregate initialization for types with non-aggregate base classes. For example:
struct A { A(int); }; struct B : A {}; B b = {42}; // OK in C++1z
Add tests that explicit default constructors are still allowed outside of copy-initialization.
Do we correctly handle the "or inherited" part? I'd also like to find out whether core intended for this issue to be treated as a DR or not (if so, this should apply all the way back to C++11).