Bug 101848 - Template metaprogramming errors in v11.1
Summary: Template metaprogramming errors in v11.1
Status: RESOLVED DUPLICATE of bug 85282
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-10 15:10 UTC by qwdkguneykiffmmuyd
Modified: 2021-08-10 15:27 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Preprocessed file (4.56 KB, text/plain)
2021-08-10 15:10 UTC, qwdkguneykiffmmuyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description qwdkguneykiffmmuyd 2021-08-10 15:10:53 UTC
Created attachment 51285 [details]
Preprocessed file

This program fails to compile with g++ 11.1.0 with the following template errors, but DOES compile and execute with clang++ 12.0.1 on the same hardware. It is reported here in case such behavior is not intended. As instructed, the preprocessed file is included but not the original CPP file, which was explicitly listed as not to include.

+verbatim+
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC) 
-verbatim-


+verbatim+
$ g++ kirktemp.cpp 
kirktemp.cpp:60:12: error: explicit specialization in non-namespace scope ‘struct ValidSched<numdays>’
   60 |   template<> struct daytriad<numdays-1>
      |            ^
kirktemp.cpp:60:21: error: too few template-parameter-lists
   60 |   template<> struct daytriad<numdays-1>
      |                     ^~~~~~~~~~~~~~~~~~~
kirktemp.cpp: In instantiation of ‘struct ValidSched<1>::daytriad<0>’:
kirktemp.cpp:52:82:   recursively required from ‘struct ValidSched<34>::daytriad<0>’
kirktemp.cpp:52:82:   required from ‘struct ValidSched<35>::daytriad<0>’
kirktemp.cpp:71:28:   required from ‘static void ValidSched<numdays>::printschedule() [with int numdays = 35]’
kirktemp.cpp:83:19:   required from here
kirktemp.cpp:52:82: error: invalid use of incomplete type ‘struct ValidSched<0>::daytriad<0>’
   52 |     typedef typename ValidSched<numdays-1>::template daytriad<day>::thisdaytriad thisdaytriad;
      |                                                                                  ^~~~~~~~~~~~
kirktemp.cpp:78:24: note: declaration of ‘struct ValidSched<0>::daytriad<0>’
   78 |   template<int> struct daytriad;
      |                        ^~~~~~~~

-verbatim-
Comment 1 Richard Biener 2021-08-10 15:25:47 UTC
Confirmed.  clang takes quite some time compiling this.
Comment 2 Andrew Pinski 2021-08-10 15:27:46 UTC
It is only valid C++17 :).

*** This bug has been marked as a duplicate of bug 85282 ***