From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B2321385803E; Sat, 16 Apr 2022 08:51:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2321385803E From: "sbergman at redhat dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/105291] New: include/c++/12.0.1/debug/safe_unordered_container.h:71:28: error: captured variable '__local_end' cannot appear here Date: Sat, 16 Apr 2022 08:51:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sbergman at redhat 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: Sat, 16 Apr 2022 08:51:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105291 Bug ID: 105291 Summary: include/c++/12.0.1/debug/safe_unordered_container.h:71 :28: error: captured variable '__local_end' cannot appear here Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com Target Milestone: --- Since "[clang] Implement Change scope of lambda trailing-return-type", Clang 15 t= runk implements "Cha= nge scope of lambda trailing-return-type" as a DR (in line with "N4902 Editors=E2=80=99 Report =E2=80=93 Programming Languages =E2=80=93 C++"; so = enabled with all -std=3D versions). That stated to cause > $ cat test.cc=20 > #define _GLIBCXX_DEBUG > #include > $ clang++ -fsyntax-only test.cc > In file included from test.cc:2: > In file included from /usr/lib/gcc/x86_64-redhat-linux/12/../../../../inc= lude/c++/12/unordered_map:52: > In file included from /usr/lib/gcc/x86_64-redhat-linux/12/../../../../inc= lude/c++/12/debug/unordered_map:49: > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/safe= _unordered_container.h:71:28: error: captured variable '__local_end' cannot= appear here > [__local_end](__decltype(__local_end) __it) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/safe= _unordered_container.h:71:4: note: variable '__local_end' is explicitly cap= tured here > [__local_end](__decltype(__local_end) __it) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/safe= _unordered_container.h:69:2: note: '__local_end' declared here > auto __local_end =3D _M_cont()._M_base().cend(0); > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/safe= _unordered_container.h:169:44: error: captured variable '__end' cannot appe= ar here > this->_M_invalidate_if([__end](__decltype(__end) __it) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/safe= _unordered_container.h:169:26: note: variable '__end' is explicitly capture= d here > this->_M_invalidate_if([__end](__decltype(__end) __it) > ^ > /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/debug/safe= _unordered_container.h:168:2: note: '__end' declared here > auto __end =3D _M_cont()._M_base().cend(); > ^ > 2 errors generated. to fail. The relevant code in libstdc++-v3/include/debug/safe_unordered_container.h = got added with "2018-10-24 Fran=C3=A7ois Dumont ". What made things work for me is > diff --git a/libstdc++-v3/include/debug/safe_unordered_container.h b/libs= tdc++-v3/include/debug/safe_unordered_container.h > index 91be256611a..71468198573 100644 > --- a/libstdc++-v3/include/debug/safe_unordered_container.h > +++ b/libstdc++-v3/include/debug/safe_unordered_container.h > @@ -67,8 +67,9 @@ namespace __gnu_debug > _M_invalidate_locals() > { > auto __local_end =3D _M_cont()._M_base().cend(0); > + using __local_end_t =3D __decltype(__local_end); > this->_M_invalidate_local_if( > - [__local_end](__decltype(__local_end) __it) > + [__local_end](__local_end_t __it) > { return __it !=3D __local_end; }); > } >=20=20 > @@ -166,7 +167,8 @@ namespace __gnu_debug > _M_invalidate_all() > { > auto __end =3D _M_cont()._M_base().cend(); > - this->_M_invalidate_if([__end](__decltype(__end) __it) > + using __end_t =3D __decltype(__end); > + this->_M_invalidate_if([__end](__end_t __it) > { return __it !=3D __end; }); > _M_invalidate_locals(); > }=