struct B { }; struct D : B { int i; }; int main() { auto [i] = D{}; } On gcc 7.2, this fails with: sb.cxx:5:10: error: cannot decompose class type ‘D’: both it and its base class ‘D’ have non-static data members auto [i] = D{}; ^~~ But this is well-formed - all of D's non-static data members are public direct members of D.
Confirmed that gcc errors on the example.
cc-ing C++ FE maintainers for their interpretation
This is accepted in 8.x and on the trunk starting with r257057 aka PR84031 fix and it has been backported to 7.x too.
Author: jakub Date: Fri Mar 8 18:31:27 2019 New Revision: 269504 URL: https://gcc.gnu.org/viewcvs?rev=269504&root=gcc&view=rev Log: PR c++/82075 * g++.dg/cpp1z/decomp49.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1z/decomp49.C Modified: trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Tue Apr 30 20:38:32 2019 New Revision: 270722 URL: https://gcc.gnu.org/viewcvs?rev=270722&root=gcc&view=rev Log: Backported from mainline 2019-03-08 Jakub Jelinek <jakub@redhat.com> PR c++/82075 * g++.dg/cpp1z/decomp49.C: New test. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/cpp1z/decomp49.C Modified: branches/gcc-8-branch/gcc/testsuite/ChangeLog
Author: jakub Date: Fri Aug 30 12:14:10 2019 New Revision: 275125 URL: https://gcc.gnu.org/viewcvs?rev=275125&root=gcc&view=rev Log: Backported from mainline 2019-03-08 Jakub Jelinek <jakub@redhat.com> PR c++/82075 * g++.dg/cpp1z/decomp49.C: New test. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1z/decomp49.C Modified: branches/gcc-7-branch/gcc/testsuite/ChangeLog