The following code worked well on GCC-7.1, but fails on GCC-7.2 with -std=c++17: struct do_not_define_std_tuple_size_for_me { bool test1 = true; }; template <class T> bool is_structured_bindings_work() noexcept { auto [a] = T{}; return a; } const bool do_not_use = is_structured_bindings_work<do_not_define_std_tuple_size_for_me>(); Error message: error: invalid initializer for structured binding declaration auto [a] = T{}; ^~~ Fix from Bug 78939 does not resolves the issue. Clang-4.0 and GCC-7.1 compile the code well.
Confirmed. The feature was new in GCC 7.
Started with my r249947 aka PR81258 fix.
Created attachment 42696 [details] gcc8-pr81888.patch Untested fix.
Author: jakub Date: Mon Nov 27 21:54:25 2017 New Revision: 255180 URL: https://gcc.gnu.org/viewcvs?rev=255180&root=gcc&view=rev Log: PR c++/81888 * parser.c (cp_parser_decomposition_declaration): Reject just BRACE_ENCLOSED_INITIALIZER_P initializers with nelts != 1 rather than all such CONSTRUCTORs, and only if is_direct_init is true. * g++.dg/cpp1z/decomp30.C: Add a test for structured binding with = {} and = { a, a } initializers. * g++.dg/cpp1z/decomp31.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1z/decomp31.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/cpp1z/decomp30.C
Fixed on the trunk so far.
Author: jakub Date: Fri Dec 15 22:07:23 2017 New Revision: 255719 URL: https://gcc.gnu.org/viewcvs?rev=255719&root=gcc&view=rev Log: Backported from mainline 2017-11-27 Jakub Jelinek <jakub@redhat.com> PR c++/81888 * parser.c (cp_parser_decomposition_declaration): Reject just BRACE_ENCLOSED_INITIALIZER_P initializers with nelts != 1 rather than all such CONSTRUCTORs, and only if is_direct_init is true. * g++.dg/cpp1z/decomp30.C: Add a test for structured binding with = {} and = { a, a } initializers. * g++.dg/cpp1z/decomp31.C: New test. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1z/decomp31.C Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/parser.c branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/testsuite/g++.dg/cpp1z/decomp30.C
Fixed for 7.3+.