From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: leon zadorin <leonleon77@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: C++ expected-to-fail compilation goes through by not detecting mutable-specifier on lambda...
Date: Tue, 03 Mar 2020 10:57:00 -0000 [thread overview]
Message-ID: <CAH6eHdS+7gY-+0Gt04+6eQxm6eVQe7YzKsc=zomWU+u4ww+Lqg@mail.gmail.com> (raw)
In-Reply-To: <CAPpySAazT8-1Rv3iieg7pOUeYnaPmg_+gSoLyRKbnDbj4En66w@mail.gmail.com>
On Mon, 2 Mar 2020 at 03:55, leon zadorin <leonleon77@gmail.com> wrote:
>
> On Mon, Mar 2, 2020 at 1:57 PM leon zadorin <leonleon77@gmail.com> wrote:
> >
> > template<typename T>
> > void foo(T const f)
> > {
> > f();
> > }
> ...
> > the effect of 'mutable' (i.e. making operator()() non-const) are not
> detected by GCC/clang to a point where both of the following compile ok:
> > int main()
> > {
> > foo([](){});
> > foo([]() mutable {});
> > }
> >
>
> ... actually never mind, I take it back :) I think GCC/clang are ok in
> that regard, reading https://en.cppreference.com/w/cpp/language/lambda
> "mutable: allows body to modify the parameters captured by copy, and to
> call their non-const member functions"
>
> makes it more clear for me... as in the above lambdas have no captures
> anyways (i.e. no effect), and with any captures (e.g. mutating with
> mutable) the expected compilation failure becomes evident, so in effect
> GCC/clang are doing this fine :)
What they're doing seems kinda OK, but I think it's not actually
allowed by the standard. The wording does say that unless the lambda
uses the mutable keyword, the function call operator is
const-qualified.
So I think this is a bug.
next prev parent reply other threads:[~2020-03-03 10:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 2:57 leon zadorin
2020-03-02 3:55 ` leon zadorin
2020-03-03 10:57 ` Jonathan Wakely [this message]
2020-03-04 1:54 ` leon zadorin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH6eHdS+7gY-+0Gt04+6eQxm6eVQe7YzKsc=zomWU+u4ww+Lqg@mail.gmail.com' \
--to=jwakely.gcc@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=leonleon77@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).