From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 989003858408; Mon, 4 Oct 2021 11:06:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 989003858408 From: "1997.rajatjain at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102590] New: Templated operations on variables in structured binding don't work when templated functions/lambdas require type deduction Date: Mon, 04 Oct 2021 11:06:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 1997.rajatjain at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2021 11:06:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102590 Bug ID: 102590 Summary: Templated operations on variables in structured binding don't work when templated functions/lambdas require type deduction Product: gcc Version: 8.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: 1997.rajatjain at gmail dot com Target Milestone: --- Foreach loops written with a structured-binding declaration error out if an= y of the captured types contains a template member-function which is used inside= the loop. This only happens if such a loop is placed inside a templated lambda/functi= on. A minimal example of the above is: struct Foo { template T get() const { return static_cast(0); } }; template void error_func(T elem) { std::array, 1> arr; for(const auto& [_, val] : arr) { val.get(); // Error here } } The error disappears if T is replaced with any concrete type. It also disappears if instead of structured bindings, a tuple is used with auto type specifier. The above code also works if one writes: const auto& [_, val] =3D arr[0]; val.get(); Compilation flags: -std=3Dc++17 Reported error: test.cpp:19:17: error: expected primary-expression before 'int' val.get(); ^~~ test.cpp:19:17: error: expected ';' before 'int' val.get(); ^~~ ;=