This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/42473] New: error parsing template syntax
- From: "sodiumgood at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Dec 2009 06:44:30 -0000
- Subject: [Bug c++/42473] New: error parsing template syntax
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The compiler failed to parse the template syntax in the line:
Derived(int arg0 = Base<T0,T1>::var){}
which is a constructor definition of the class called Derived.
However, if we replace 'Base<T0,T1>' with an alias, the error no longer occurs:
typedef Base<T0,T1> B
Derived(int arg0 = B::var){}
If Base has three template arguments, the same errors occur. However, if Base
has only one template argument, it is parsed correctly.
Command line output:
$ g++ -v -save-temps Driver.cpp
Using built-in specs.
Target: i586-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3
--enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
--with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap
--with-slibdir=/lib --with-system-zlib --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.3
--enable-linux-futex --without-system-libunwind --with-cpu=generic
--build=i586-suse-linux
Thread model: posix
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
/usr/lib/gcc/i586-suse-linux/4.3/cc1plus -E -quiet -v -D_GNU_SOURCE Driver.cpp
-mtune=generic -fpch-preprocess -o Driver.ii
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.3
/usr/include/c++/4.3/i586-suse-linux
/usr/include/c++/4.3/backward
/usr/local/include
/usr/lib/gcc/i586-suse-linux/4.3/include
/usr/lib/gcc/i586-suse-linux/4.3/include-fixed
/usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/include
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
/usr/lib/gcc/i586-suse-linux/4.3/cc1plus -fpreprocessed Driver.ii -quiet
-dumpbase Driver.cpp -mtune=generic -auxbase Driver -version -o Driver.s
GNU C++ (SUSE Linux) version 4.3.2 [gcc-4_3-branch revision 141291]
(i586-suse-linux)
compiled by GNU C version 4.3.2 [gcc-4_3-branch revision 141291], GMP
version 4.2.3, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 89a9a4976d191f1d4bdfbbb11623edc8
Driver.cpp:48: error: expected ',' or '...' before '>' token
Driver.cpp:48: error: wrong number of template arguments (1, should be 2)
Driver.cpp:36: error: provided for 'template<class T0, class T1> class Base'
Driver.cpp:48: error: default argument missing for parameter 2 of 'Derived<T0,
T1>::Derived(int, T1)'
Codes:
template<typename T0, typename T1> class Base{
public:
Base(){}
static int var;
};
template<typename T0,typename T1> int Base<T0,T1>::var = 10;
template<typename T0,typename T1>
class Derived : public Base<T0,T1>{
public:
Derived(int arg0 = Base<T0,T1>::var){}
};
int main(){
Derived<int,char> d;
return 0;
}
--
Summary: error parsing template syntax
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sodiumgood at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42473