Bug 82075 - structured binding fails with empty base class
Summary: structured binding fails with empty base class
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2017-09-01 16:03 UTC by Barry Revzin
Modified: 2019-09-01 17:24 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-09-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Revzin 2017-09-01 16:03:53 UTC
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.
Comment 1 Eric Gallager 2017-09-05 15:55:09 UTC
Confirmed that gcc errors on the example.
Comment 2 Eric Gallager 2019-03-08 17:52:56 UTC
cc-ing C++ FE maintainers for their interpretation
Comment 3 Jakub Jelinek 2019-03-08 18:16:00 UTC
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.
Comment 4 Jakub Jelinek 2019-03-08 18:31:59 UTC
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
Comment 5 Jakub Jelinek 2019-04-30 20:39:03 UTC
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
Comment 6 Jakub Jelinek 2019-08-30 12:14:41 UTC
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