public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95368] New: gcc things that a lambda capture is both const and mutable
@ 2020-05-27 15:24 rafael at espindo dot la
  2020-05-27 16:35 ` [Bug c++/95368] " daniel.kruegler at googlemail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rafael at espindo dot la @ 2020-05-27 15:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95368
           Summary: gcc things that a lambda capture is both const and
                    mutable
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafael at espindo dot la
  Target Milestone: ---

gcc accepts

#include <utility>

struct foo {
    void func();
};

void bar(foo& v) {
    [v]() {
        static_assert(std::is_same_v<decltype(v), foo&>);
        [v]() mutable {
            static_assert(std::is_same_v<decltype(v), foo&>);
//            v.func();                                                         
        }();
    }();
}


But uncomment the call and you get

test.cc:12:20: error: passing ‘const foo’ as ‘this’ argument discards
qualifiers [-fpermissive]
   12 |             v.func();

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

end of thread, other threads:[~2021-12-28 10:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 15:24 [Bug c++/95368] New: gcc things that a lambda capture is both const and mutable rafael at espindo dot la
2020-05-27 16:35 ` [Bug c++/95368] " daniel.kruegler at googlemail dot com
2020-05-28 17:00 ` rafael at espindo dot la
2021-12-28  9:55 ` pinskia at gcc dot gnu.org
2021-12-28  9:56 ` pinskia at gcc dot gnu.org
2021-12-28 10:01 ` pinskia 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).