public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99088] New: Failure to error on recursive template instantiation in a reasonable time
@ 2021-02-13 19:35 gabravier at gmail dot com
  2021-02-15 17:33 ` [Bug c++/99088] " ppalka at gcc dot gnu.org
  2021-11-08  8:39 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: gabravier at gmail dot com @ 2021-02-13 19:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99088
           Summary: Failure to error on recursive template instantiation
                    in a reasonable time
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

template<class T>struct W{T v;W(T v):v(v){}};
template<class T>int f(T x){f(W<T>(x));}
int main(){f(0);}

This seems to make GCC lag out for an *extremely* long time (at least long
enough that Godbolt kills GCC (20 seconds), I personally do not have a build of
trunk GCC to test this bug on). On GCC 10 and before, this resulted in an error
in a reasonable amount of time (<1 second)

-v output:

Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-snapshot/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-trunk-20210213/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran,ada,d
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210212 (experimental) (Compiler-Explorer-Build) 
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' './output.s'
'-masm=intel' '-S' '-O3' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' './'

/opt/compiler-explorer/gcc-trunk-20210213/bin/../libexec/gcc/x86_64-linux-gnu/11.0.0/cc1plus
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir ./ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -O3 -version
-fdiagnostics-color=always -o ./output.s
GNU C++17 (Compiler-Explorer-Build) version 11.0.0 20210212 (experimental)
(x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/backward"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.0.0/include"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.0.0/include-fixed"
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0

/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/x86_64-linux-gnu

/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/backward

/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/include

/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/include-fixed
 /usr/local/include
 /opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/../../include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++17 (Compiler-Explorer-Build) version 11.0.0 20210212 (experimental)
(x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: a47483d85f54b7b7df3d6a6237220aa1
COMPILER_PATH=/opt/compiler-explorer/gcc-trunk-20210213/bin/../libexec/gcc/x86_64-linux-gnu/11.0.0/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../libexec/gcc/x86_64-linux-gnu/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../libexec/gcc/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/bin/
LIBRARY_PATH=/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/lib/:/opt/compiler-explorer/gcc-trunk-20210213/bin/../lib/gcc/x86_64-linux-gnu/11.0.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' './output.s'
'-masm=intel' '-S' '-O3' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
'-dumpdir' './output.'

Godbolt link where I got the error: https://godbolt.org/z/16oh6e

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99088] Failure to error on recursive template instantiation in a reasonable time
  2021-02-13 19:35 [Bug c++/99088] New: Failure to error on recursive template instantiation in a reasonable time gabravier at gmail dot com
@ 2021-02-15 17:33 ` ppalka at gcc dot gnu.org
  2021-11-08  8:39 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-02-15 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
GCC 11 appears to be much slower than GCC 10 here because snapshots of trunk
are by default built with extra checking enabled, and your testcase is
exercising a check in the type comparison code that seems to be quadratic in
the depth of the template instantiation.  Release builds (by default) don't
perform this particular check, which is why GCC 10 appears to be much faster. 
You can disable most of these sanity checks when using snapshots of trunk by
passing -fno-checking to the compile command line.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/99088] Failure to error on recursive template instantiation in a reasonable time
  2021-02-13 19:35 [Bug c++/99088] New: Failure to error on recursive template instantiation in a reasonable time gabravier at gmail dot com
  2021-02-15 17:33 ` [Bug c++/99088] " ppalka at gcc dot gnu.org
@ 2021-11-08  8:39 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-08  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
With -fno-checking, GCC compiling errors out really quickly.

Without -fno-checking on the trunk takes around 20s.
With -fno-checking on the trunk takes 1.2s.

I don't think there is anything to fix here really. checking will always be
slower.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-08  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-13 19:35 [Bug c++/99088] New: Failure to error on recursive template instantiation in a reasonable time gabravier at gmail dot com
2021-02-15 17:33 ` [Bug c++/99088] " ppalka at gcc dot gnu.org
2021-11-08  8:39 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).