This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/82470] New: Structured bindings don't work with std::tuple if a type has a get member function
- From: "morwenn29 at hotmail dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 07 Oct 2017 22:50:23 +0000
- Subject: [Bug libstdc++/82470] New: Structured bindings don't work with std::tuple if a type has a get member function
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82470
Bug ID: 82470
Summary: Structured bindings don't work with std::tuple if a
type has a get member function
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: morwenn29 at hotmail dot fr
Target Milestone: ---
Here is a simple example of failing code:
struct foobar
{
template<std::size_t N>
int get() { return N; }
};
int main()
{
std::tuple<int, foobar> tu;
auto [a, b] = tu;
}
The compiler complains about the function foobar::get being unaccessible. This
is caused by the packing behaviour of std::tuple: foobar begin an empty class,
std::tuple will attempt EBCO and eventually privately inherit from foobar.
Structured bindings first look for a get member function in std::tuple<int,
foobar>, and find foobar::get because it has the correct interface and
std::tuple inherits from foobar. However the private inheritance makes the
function inaccessible and triggers a compiler error accordingly.
I don't know whether it's possible to solve the problem while keeping the full
EBCO capabilities, save for a change in structured bindings lookup rules.