public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105291] New: include/c++/12.0.1/debug/safe_unordered_container.h:71:28: error: captured variable '__local_end' cannot appear here
@ 2022-04-16  8:51 sbergman at redhat dot com
  2022-04-16 13:35 ` [Bug libstdc++/105291] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sbergman at redhat dot com @ 2022-04-16  8:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105291

            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
<https://github.com/llvm/llvm-project/commit/04000c2f928a7adc32138a664d167f01b642bef3>
"[clang] Implement Change scope of lambda trailing-return-type", Clang 15 trunk
implements
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2036r3.html> "Change
scope of lambda trailing-return-type" as a DR (in line with
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/n4902.html> "N4902
Editors’ Report – Programming Languages – C++"; so enabled with all -std=
versions).

That stated to cause

> $ cat test.cc 
> #define _GLIBCXX_DEBUG
> #include <unordered_map>

> $ clang++ -fsyntax-only test.cc
> In file included from test.cc:2:
> In file included from /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/unordered_map:52:
> In file included from /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/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 captured 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 = _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 appear 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 captured 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 = _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
<https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=4b763deedb282b480fe4c2b3a8ad07192393f1b1>
"2018-10-24  François Dumont  <fdumont@gcc.gnu.org>".

What made things work for me is

> diff --git a/libstdc++-v3/include/debug/safe_unordered_container.h b/libstdc++-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 = _M_cont()._M_base().cend(0);
> +       using __local_end_t = __decltype(__local_end);
>         this->_M_invalidate_local_if(
> -               [__local_end](__decltype(__local_end) __it)
> +               [__local_end](__local_end_t __it)
>                 { return __it != __local_end; });
>        }
>  
> @@ -166,7 +167,8 @@ namespace __gnu_debug
>        _M_invalidate_all()
>        {
>         auto __end = _M_cont()._M_base().cend();
> -       this->_M_invalidate_if([__end](__decltype(__end) __it)
> +       using __end_t = __decltype(__end);
> +       this->_M_invalidate_if([__end](__end_t __it)
>                                { return __it != __end; });
>         _M_invalidate_locals();
>        }

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-19 12:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-16  8:51 [Bug libstdc++/105291] New: include/c++/12.0.1/debug/safe_unordered_container.h:71:28: error: captured variable '__local_end' cannot appear here sbergman at redhat dot com
2022-04-16 13:35 ` [Bug libstdc++/105291] " redi at gcc dot gnu.org
2022-04-16 13:39 ` redi at gcc dot gnu.org
2022-04-16 14:18 ` redi at gcc dot gnu.org
2022-04-17 14:36 ` corentinjabot at gmail dot com
2022-04-19 12:11 ` sbergman at redhat dot com
2022-04-19 12:15 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).