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

            Bug ID: 108254
           Summary: Usage of requires expression with an immedietely
                    invoked lambda expression results in compile error
                    instead of evaluating to false
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avr5309 at gmail dot com
  Target Milestone: ---

Substitution failure of an immedietely invoked lambda expression within an
requires expression results in a compile error instead of the requires
expression evaluating to 'false' (by my understanding of 
http://eel.is/c++draft/expr.prim.req#general-5 . Clang 15 comforms to my
expectation).

### SOURCE:

The single source file (bug.cpp):-

template <class T>
concept Container = requires(T t) {
    {
        [](T const& t){
            for(auto&& v : t)
                ;
        }(t)
    };
};

int main() {
    static_assert(!Container<int>);
}

### COMPILER INVOCATION:

g++ -fsyntax-only -std=c++20 -Wall -Wextra -pedantic-errors -xc++ -

### ACTUAL OUTPUT:

The following error message:-

bug.cpp: In lambda function:
bug.cpp:5:13: error: 'begin' was not declared in this scope
    5 |             for(auto&& v : t)
      |             ^~~
bug.cpp:5:13: error: 'end' was not declared in this scope
bug.cpp: In function 'int main()':
bug.cpp:12:19: error: static assertion failed
   12 |     static_assert(!Container<int>);
      |                   ^~~~~~~~~~~~~~~

### EXPECTED OUTPUT:

(clean compile)

### COMPILER VERSION INFO (g++ -v):

Reading specs from /usr/lib64/gcc/x86_64-unknown-linux-gnu/12.2.0/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-unknown-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /builddir/gcc-12.2.0/configure
--build=x86_64-unknown-linux-gnu --enable-gnu-unique-object
--enable-vtable-verify --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --libexecdir=/usr/lib64 --libdir=/usr/lib64
--enable-threads=posix --enable-__cxa_atexit --disable-multilib
--with-system-zlib --enable-shared --enable-lto --enable-plugins
--enable-linker-build-id --disable-werror --disable-nls --enable-default-pie
--enable-default-ssp --enable-checking=release --disable-libstdcxx-pch
--with-isl --with-linker-hash-style=gnu --disable-sjlj-exceptions
--disable-target-libiberty
--enable-languages=c,c++,objc,obj-c++,fortran,lto,go,ada
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)

Reply via email to