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

            Bug ID: 117775
           Summary: Internal compiler error when deriving from lambda
                    function with invalid body
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thor at stheno dot org
  Target Milestone: ---

Created attachment 59701
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59701&action=edit
A minimal testcase exhibiting the bug

The compiler fails to recognise the attached program as invalid; instead it
fails with an internal compiler error. To reproduce, simply compile the
attached program with:
g++ -std=c++20 bug.cpp

I did not include a preprocessed source file as per the detailed instructions
as I have constructed a minimal test case of 5 lines, including no other files
at all.

This appears to be a regression, since on my Ubuntu 24.04 machine it works for
"gcc version 12.3.0 (Ubuntu 12.3.0-17ubuntu1)" but not "gcc version 13.2.0
(Ubuntu 13.2.0-23ubuntu4)" or "gcc version 14.2.0 (Ubuntu
14.2.0-4ubuntu2~24.04)".

The compiler output in question:

bug.cpp: In lambda function:
bug.cpp:3:50: warning: invalid application of ‘sizeof’ to a void type
[-Wpointer-arith]
    3 |     struct why : public decltype([](auto){return sizeof(void);}){} x;
      |                                                  ^~~~~~~~~~~~
bug.cpp: In instantiation of ‘main()::why::<lambda(auto:1)> [with auto:1 =
int]’:
bug.cpp:4:24:   required from here
    4 |     return x.operator()(0);
      |            ~~~~~~~~~~~~^~~
bug.cpp:3:50: warning: invalid application of ‘sizeof’ to a void type
[-Wpointer-arith]
    3 |     struct why : public decltype([](auto){return sizeof(void);}){} x;
      |                                                  ^~~~~~~~~~~~
bug.cpp: In function ‘int main()’:
bug.cpp:4:24:   in ‘constexpr’ expansion of
‘((main()::why::<lambda(auto:1)>*)(& x))->main()::why::<lambda(auto:1)>(0)’
bug.cpp:3:61: internal compiler error: in cxx_eval_store_expression, at
cp/constexpr.cc:6589
    3 |     struct why : public decltype([](auto){return sizeof(void);}){} x;
      |                                                             ^
0x793bf9e2a1c9 __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x793bf9e2a28a __libc_start_main_impl
        ../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.


Output from gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
14.2.0-4ubuntu2~24.04' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr
--with-gcc-major-version-only --program-suffix=-14
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-14-ig5ci0/gcc-14-14.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-14-ig5ci0/gcc-14-14.2.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Ubuntu 14.2.0-4ubuntu2~24.04)

Reply via email to