public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "abutcher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61636] generic lambda  "cannot call member function without object"
Date: Mon, 07 Jul 2014 07:08:00 -0000	[thread overview]
Message-ID: <bug-61636-4-VdDipkcO23@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-61636-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #8 from Adam Butcher <abutcher at gcc dot gnu.org> ---
(In reply to tower120 from comment #7)
> I'm not sure what you mean, about adding "this->". 
>
I meant spelling "fn1(data)" as "this->fn1(data)" to explicitly specify the
subject of the member call. 

> But this case is not working :
> http://coliru.stacked-crooked.com/a/d69de477f9a746cb
> 
> But to be true, it not work with clang either.
>
In the case you link to, specifically within the member function template 'go',

        std::cout << if_else<do_it>(
                            [&]{ return this->fn1(data); },
                            [&]{ return this->fn2(data); }

                ) << '\n';

you are building up two non-generic (non-template) lambdas that are not
dependent  on any template parameter.  The if_else is, but the two arguments
are not.  Both have to be evaluated to pass to the if_else.  Because they are
not templates, the body of both lambdas must be well formed within 'go'.  'fn1'
and 'fn2' are both being passed 'data' which is either of type 'A' or of type
'B'.  There are no overloads of 'fn1' that can accept a 'B'.  That's what both
clang and g++ are getting at in their diagnostics.

The fact that g++ proceeds to ICE on recovery is another issue.


  parent reply	other threads:[~2014-07-07  7:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-28  8:13 [Bug c++/61636] New: " tower120 at gmail dot com
2014-06-28  8:22 ` [Bug c++/61636] " tower120 at gmail dot com
2014-06-28  8:55 ` paolo.carlini at oracle dot com
2014-06-28 13:17 ` tower120 at gmail dot com
2014-07-06 19:58 ` abutcher at gcc dot gnu.org
2014-07-06 20:15 ` abutcher at gcc dot gnu.org
2014-07-06 20:39 ` abutcher at gcc dot gnu.org
2014-07-07  7:08 ` abutcher at gcc dot gnu.org [this message]
2014-07-07  7:15 ` abutcher at gcc dot gnu.org
2014-07-26  7:10 ` contact at jeaye dot com
2015-03-09 23:58 ` abutcher at gcc dot gnu.org
2015-03-10  0:37 ` abutcher at gcc dot gnu.org
2015-07-06 12:15 ` trippels at gcc dot gnu.org
2015-10-13 11:28 ` redi at gcc dot gnu.org

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=bug-61636-4-VdDipkcO23@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).