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

            Bug ID: 115604
           Summary: Absurd "flows off the end of the function" diagnostic
                    with requires expression containing lambda
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

Clearly the following function returns true. When calling it in a constant
expression, GCC thinks it does not have a return statement at all.

### SOURCE (<stdin>):
constexpr bool f() {
  return requires {
    [] {};
  };
}

static_assert(f());

### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++23 -xc++ -

### COMPILER OUTPUT:
<stdin>:7:16: error: non-constant condition for static assertion
<stdin>:7:16:   in 'constexpr' expansion of 'f()'
<stdin>:7:16: error: 'constexpr' call flows off the end of the function

### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240623 (experimental) (GCC)
  • [Bug c++/115604] New: Absurd "... hstong at ca dot ibm.com via Gcc-bugs

Reply via email to