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

            Bug ID: 120124
           Summary: "g++: fatal error: Killed signal..." when reporting
                    error involving very complex lambda type
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: whiteredredcat at gmail dot com
  Target Milestone: ---

Created attachment 61333
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61333&action=edit
pre-processed bug file.

g++ crashes when trying to print an error involving an extremely long type,
constructed with lambdas. If there is no error, g++ successfully compiles the
file. clang++ successfully reports the error, with no delay.

I suspect the problem is that g++ always prints the full type name no matter
how complex, and lambdas allow me to construct a problematically long type name
fast enough that I don't run into the template recursion limit first.

The error and command is below:
```
$~/patches/gcc-compile/built/bin/g++ --std=c++23 bug.cpp -save-temps
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
```
I must wait a long time before getting the above error. 

my gcc version from g++ -v
```
Using built-in specs.
COLLECT_GCC=/home/plum/patches/gcc-compile/built/bin/g++
COLLECT_LTO_WRAPPER=/home/plum/patches/gcc-compile/built/libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/plum/patches/gcc-compile/../gcc/configure
--prefix=/home/plum/patches/gcc-compile/built --enable-language=c,c++ :
(reconfigured) /home/plum/patches/gcc-compile/../gcc/configure
--prefix=/home/plum/patches/gcc-compile/built --enable-language=c,c++
--enable-languages=c,c++,fortran,lto,objc --no-create --no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.0 20250506 (experimental) (GCC) 
``


bug.cpp
```
struct foo_tag {};

template<class T> struct foo {
        using tag = foo_tag;
        T run;
};

template<class T> concept isFoo = requires(T a) {a.run();};

//function to construct very complex type with lambda
template<int i, class T> auto complexify(T a) requires isFoo<T> {
        if constexpr (i > 0) {
                return complexify<i-1>(foo{ [a]{
                        return 1+a.run();
                }});
        } else return a;
}

//base case
template<int i> auto complexify(int a) {
        return complexify<i-1>(foo{ [a]{
                return a;
        }});
}

int main() {
        auto a = complexify<100>(1);
        int result = a.run(1); //<-- this times out because it is an error
        //int result = a.run(); //<-- this compiles fine

        return result;  
}
// vim: ts=2 sw=2
```

Attached is the a-bug.ii file.

Reply via email to