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

            Bug ID: 114638
           Summary: Hang and Memory Consumption Increase during
                    Compilation with Recursive Template Instantiation
           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

struct Z
{
  Z () = default;
  Z (Z const &) = default;
  constexpr Z (Z &&) {}
};

template < typename T > 
constexpr int 
fn (T v)
{
  return fn (v);
}

auto t = fn (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z
(Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z
(Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z (Z ());

============================================
The code with this syntax error should promptly output a compilation error
instead of hanging indefinitely and depleting memory resources. 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) 
============================================

Reply via email to