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: unassig...@gcc.gnu.org
        ReportedBy: igod...@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.

Reply via email to