[Bug c++/101848] New: Template metaprogramming errors in v11.1

qwdkguneykiffmmuyd at uivvn dot net gcc-bugzilla@gcc.gnu.org
Tue Aug 10 15:10:53 GMT 2021


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

            Bug ID: 101848
           Summary: Template metaprogramming errors in v11.1
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: qwdkguneykiffmmuyd at uivvn dot net
  Target Milestone: ---

Created attachment 51285
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51285&action=edit
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-


More information about the Gcc-bugs mailing list