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

            Bug ID: 93442
           Summary: lambda in if constexpr fails to compile
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mail at dominicp dot de
  Target Milestone: ---

the following code:
------------------------------
struct bar {
    int foo(){return 0;}
};

int foobar() {
    if constexpr(true) {
        return 0;
    } else {
        return [](){
            return bar{};
        }().foo();
    }
}
-------------------------------
is rejected with following error:
-------------------------------
<source>: In function 'int foobar()':

<source>:11:10: error: invalid use of 'void'

    9 |         return [](){

      |                ~~~~~

   10 |             return bar{};

      |             ~~~~~~~~~~~~~

   11 |         }().foo();

      |         ~^~

<source>:11:13: error: expected ';' before 'foo'

   11 |         }().foo();

      |             ^~~

      |             ;

<source>:11:13: error: 'foo' was not declared in this scope

   11 |         }().foo();

      |             ^~
-------------------------------------

Reply via email to