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

            Bug ID: 105999
           Summary: Wrong requires result inside lambda in a class
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egor.pugin at gmail dot com
  Target Milestone: ---

Gives x instead of y on any latest compiler.

https://godbolt.org/z/6MrvMaPoK

#include <stdio.h>
struct A {
    void g(){}
    void f() {
        []() {
            //if constexpr (requires {this->g();}) {
            if constexpr (requires {g();}) {
                printf("x");
                //g(); // cant call here
            } else {
                printf("y");
            }
        }();
    }
};
int main() {
    A{}.f();
}

Reply via email to