https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114858
Bug ID: 114858 Summary: Compilation Hang and Excessive RAM Consumption in GCC Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: iamanonymous.cs at gmail dot com Target Milestone: --- The following code snippet triggers a hang issue: ============================================ $ cat bug.cpp template <class F> void g(F); template <class... A> auto h(A &&... a) -> decltype(g(0, (g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype(g<decltype()>)(a)...)) { h([] {}); } int main() { h(); return 0; } ============================================ I observed that when attempting to compile this code using GCC, the compilation process hangs indefinitely, without providing any output or indicating successful compilation. Additionally, the RAM usage continuously increases, leading to excessive consumption of system resources. However, it is worth noting that when using LLVM as the compiler, the code compiles quickly and produces the expected compilation output. We have found that this issue still persists in the latest version of GCC(see https://godbolt.org/z/P1c7f664f) The command we used is(no error output): ============================================ g++ bug.cpp ============================================ The GCC version: ============================================ $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/home/cTest/gcc/myinstall/libexec/gcc/x86_64-linux-gnu/14.0.1/lto-wrapper Target: x86_64-linux-gnu Configured with: ../configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --enable-checking=no --enable-languages=c,c++ --disable-multilib --prefix=/home/cTest/gcc/myinstall --disable-bootstrap Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.1 20240329 (experimental) (GCC) ============================================