public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52288] New: Trouble with operator?: and lambdas
@ 2012-02-16 23:12 igodard at pacbell dot net
  2012-02-16 23:55 ` [Bug c++/52288] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: igodard at pacbell dot net @ 2012-02-16 23:12 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52288

             Bug #: 52288
           Summary: Trouble with operator?: and lambdas
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: igodard@pacbell.net


This code:

int main(int argc, char** argv) {
    bool b;
    void* p = b ? [argc](int i){ return i; } :
        [argc](int i){ return i; };
return 0; }

gets you this:

s3:~/ootbc/personal/ivan$ g++ --std=c++0x foo.cc
foo.cc: In function âint main(int, char**)â:
foo.cc:5:28: error: no match for ternary âoperator?:â in âb ? {argc} : {argc}â

which is a poor. Meanwhile this code:

int main(int argc, char** argv) {
    bool b;
    void* p = b ? &[argc](int i){ return i; } :
        &[argc](int i){ return i; };
return 0; }

gets you this:

s3:~/ootbc/personal/ivan$ g++ --std=c++0x foo.cc
foo.cc: In function âint main(int, char**)â:
foo.cc:4:42: error: taking address of temporary [-fpermissive]
foo.cc:5:29: error: taking address of temporary [-fpermissive]
foo.cc:5:29: error: conditional expression between distinct pointer types
âmain(int, char**)::<lambda(int)>*â and âmain(int, char**)::<lambda(int)>*â
lacks a cast

which is even worse.


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

end of thread, other threads:[~2021-08-06  9:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 23:12 [Bug c++/52288] New: Trouble with operator?: and lambdas igodard at pacbell dot net
2012-02-16 23:55 ` [Bug c++/52288] " redi at gcc dot gnu.org
2012-02-17  0:01 ` redi at gcc dot gnu.org
2012-02-17  0:14 ` igodard at pacbell dot net
2012-02-17  0:27 ` redi at gcc dot gnu.org
2012-02-17  0:41 ` manu at gcc dot gnu.org
2014-05-09 18:29 ` jason at gcc dot gnu.org
2021-08-06  3:27 ` [Bug c++/52288] operator?: and lambdas error message could be better pinskia at gcc dot gnu.org
2021-08-06  9:18 ` 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).