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

            Bug ID: 69809
           Summary: Default member equals initialization not parsed
                    correctly.
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: c_lehmann at posteo dot de
  Target Milestone: ---

Created attachment 37682
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37682&action=edit
source code triggering the bug

When a template class (B in the example) having at least one typename and one
enum or int as template parameters has a data member (e.g. a) which is also a
template type with similar parameters, and which is default initialized using
an equals initializer, that code won't be parsed correctly.

To be more precise, here is an example.

template<typename T, EnumX E>
struct B
{
    A<T, E> a = makeA<T, E>(6); // triggers error
};

I have attached the complete source file (Btw: clang++ compiles it without
complaining).
I was running g++ 5.3.0 (from ArchLinux's repository) on x86_64.
The output of g++ was:

$ LANG=C g++ -v -Wall -o test -std=c++11 test.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-5.3.0/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++ --enable-shared
--enable-threads=posix --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --enable-multilib --disable-werror
--enable-checking=release
Thread model: posix
gcc version 5.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-Wall' '-o' 'test' '-std=c++11' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/cc1plus -quiet -v -D_GNU_SOURCE
test.cpp -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test
-Wall -std=c++11 -version -o /tmp/ccuFadlc.s
GNU C++11 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 6.1.0, MPFR version
3.1.3-p5, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0

/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/x86_64-unknown-linux-gnu

/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../../include/c++/5.3.0/backward
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include
 /usr/local/include
 /usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/include-fixed
 /usr/include
End of search list.
GNU C++11 (GCC) version 5.3.0 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 5.3.0, GMP version 6.1.0, MPFR version
3.1.3-p5, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 470612fa4d6d6f8ce43c6d7b9a2cbee6
test.cpp:32:26: error: expected ';' at end of member declaration
     A<T, E> a = makeA<T, E>(6); // does not work
                          ^
test.cpp:32:26: error: declaration of 'A<T, E> B<T, E>::E'
test.cpp:22:22: error:  shadows template parm 'EnumX E'
 template<typename T, EnumX E>
                      ^
test.cpp:32:27: error: expected unqualified-id before '>' token
     A<T, E> a = makeA<T, E>(6); // does not work
                           ^
test.cpp:32:17: error: parse error in template argument list
     A<T, E> a = makeA<T, E>(6); // does not work
                 ^

Reply via email to