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

            Bug ID: 81279
           Summary: variadic template regression : compiles without error
                    under 5.4.0 , with error under 7.1.0
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason.vas.dias at gmail dot com
  Target Milestone: ---

Created attachment 41662
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41662&action=edit
Example PieceWise Constructed (PWC) Tuple class

I would really appreciate some pointers as to how to diagnose what may be at
fault from error messages such as :


$ gcc_7_1_env
# select to use newly build GCC 7.1.0 version, installed in /usr/gcc7_1bin/ ,
# and with LD_LIBRARY_PATH set to pick up 7.1.0 libraries first

$ g++ -I. -std=gnu++14 -mtune=native -g -O2 -fPIC -pipe -pthread -D_REENTRANT \
-Wall -Wextra -Wno-unused -fno-pretty-templates -Wno-register  \
tTuple.C -o tTuple

In file included from tTuple.C:2:0:
./tuple.H: In member function 'void U::PWC::tuple<_Head,
_Tail>::_call(U::PWC::tuple<_Head, _Tail>::_ThisConstPtr_u, size_t,
U::PWC::tuple<_Head, _Tail>::_FunctionPtr_u, const _HeadList& ...) const':
./tuple.H:184:23: error: expected primary-expression before '...' token
   _t._call<  _HeadList...
                       ^~~
./tuple.H:184:23: error: expected ';' before '...' token
./tuple.H: In member function 'void U::PWC::tuple<_Head,
_Tail>::_call(U::PWC::tuple<_Head, _Tail>::_ThisConstPtr_u, size_t,
U::PWC::tuple<_Head, _Tail>::_FunctionPtr_u) const':
./tuple.H:210:19: error: expected primary-expression before '>' token
   _t._call< _Head >
                   ^
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/gcc_7_1_bin/../libexec/gcc/x86_64-pc-linux-gnu/7.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /usr/os_src/gcc-7.1.0/configure --prefix=/usr
--program-suffix=_7_1 --libdir=/usr/lib64 --enable-shared
--enable-languages=all --enable-bootstrap --enable-multilib
--with-cpu-64=haswell --with-cpu-32=atom --with-arch-64=x86-64
--with-tune-64=haswell --with-arch-32=i686 --with-tune-32=atom
--enable-targets=all --enable-threads=posix --enable-lto
--enable-serial-configure --enable-checking=release --with-gmp=/usr
--with-gmp-lib=/usr/lib64 --with-mpfr=/usr --with-mpfr-lib=/usr/lib64
--with-mpc=/usr --with-mpc-lib=/usr/lib64 --with-isl=/usr
--with-isl-lib=/usr/lib64 --with-cloog=/usr --with-cloog-lib=/usr/lib64
--with-gnu-ld --with-gnu-as --enable-linker-build-id
--disable-libunwind-exceptions --disable-nls
--enable-version-specific-runtime-libs --enable-__cxa_atexit
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--with-system-zlib --enable-java-home --with-arch-directory=x86_64
--disable-libjava-multilib --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu
Thread model: posix
gcc version 7.1.0 (GCC)




If I run :

$ un_gcc_7_1_env
# this removes /usr/gcc7_1bin from $PATH and unsets LD_LIBRARY_PATH
$ g++ -v
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/5.4.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /usr/os_src/gcc-5.4.0/configure --prefix=/usr
--libdir=/usr/lib64 --enable-shared --enable-languages=all --enable-bootstrap
--enable-multilib --with-cpu-64=haswell --with-cpu-32=atom
--with-arch-64=x86-64 --with-tune-64=haswell --with-arch-32=i686
--with-tune-32=atom --enable-targets=all --enable-threads=posix --enable-lto
--enable-serial-configure --enable-checking=release --with-gmp=/usr
--with-gmp-lib=/usr/lib64 --with-mpfr=/usr --with-mpfr-lib=/usr/lib64
--with-mpc=/usr --with-mpc-lib=/usr/lib64 --with-isl=/usr
--with-isl-lib=/usr/lib64 --with-cloog=/usr --with-cloog-lib=/usr/lib64
--with-gnu-ld --with-gnu-as --enable-linker-build-id
--disable-libunwind-exceptions --disable-nls
--enable-version-specific-runtime-libs --enable-__cxa_atexit
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--with-system-zlib --enable-java-home --with-arch-directory=x86_64
--disable-libjava-multilib --with-stage1-ldflags=-lstdc++
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
Thread model: posix
gcc version 5.4.0 (GCC)

G++ 5.4.0 compiles the same code without error or warning :

$ g++ -I. -std=gnu++14 -mtune=native -g -O2 -fPIC -pipe -pthread -D_REENTRANT
-Wall -Wextra -Wno-unused -fno-pretty-templates -Wno-register  tTuple.C -o
tTuple
$ ./tTuple
# type three strings:
one
two
three
# output:
one two three
 fun( one two three )
one
two
three
$

The example class is one I wrote several years ago for C++11, which is now
somehow broken by C++17 .  The same error is emitted by 7.1.0 regardless of 
'-std=gnu++11' OR '-std=gnu++14' OR '-std=gnu++17' option , and NO errors
are emitted by g++ 5.4.0 .

Please could anyone explain what is now broken about either my code or g++
7.1.0  ?

To reproduce:
 $ echo '#define TEST_PWC_TUPLE'$'\n''#include <tuple.H>' > tTuple.C
 $ g++ -std=gnu++17 -c tTuple.C -o /dev/null
#^ - fails if g++ >= 7.1.0, succeeds with g++ 5.4.0, g++ 6.3.0

Reply via email to