This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/44906] New: g++ is giving error: parse error in template argument list while using a c++ code.


amitavac@whileliesent-lm:~/data/prog/c++/template_ptr$g++ -v -o template
template.cpp 
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) 
COLLECT_GCC_OPTIONS='-v' '-o' 'template' '-shared-libgcc' '-mtune=generic'
'-march=i486'
 /usr/lib/gcc/i486-linux-gnu/4.4.3/cc1plus -quiet -v -D_GNU_SOURCE template.cpp
-D_FORTIFY_SOURCE=2 -quiet -dumpbase template.cpp -mtune=generic -march=i486
-auxbase template -version -fstack-protector -o /tmp/ccZiqQ9b.s
GNU C++ (Ubuntu 4.4.3-4ubuntu5) version 4.4.3 (i486-linux-gnu)
        compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version
2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.4
 /usr/include/c++/4.4/i486-linux-gnu
 /usr/include/c++/4.4/backward
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.4.3/include
 /usr/lib/gcc/i486-linux-gnu/4.4.3/include-fixed
 /usr/include
End of search list.
GNU C++ (Ubuntu 4.4.3-4ubuntu5) version 4.4.3 (i486-linux-gnu)
        compiled by GNU C version 4.4.3, GMP version 4.3.2, MPFR version
2.4.2-p1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 35224f2c24023afb0a5be7befe8d5f3f
template.cpp: In member function ?void MISC<T, P>::add(int)?:
template.cpp:55: error: parse error in template argument list
template.cpp:58: error: parse error in template argument list
template.cpp:61: error: parse error in template argument list
template.cpp:64: error: parse error in template argument list
template.cpp: In member function ?void MISC<T, P>::print(int)?:
template.cpp:72: error: parse error in template argument list
template.cpp:75: error: parse error in template argument list
template.cpp:78: error: parse error in template argument list
template.cpp:81: error: parse error in template argument list

Following is the content of template.cpp (please let me know whats wrong with
the following program):
#include<stdint.h>

#include<iostream>
#include<vector>
#include<set>

using namespace std;

template<typename T, typename P>
class MISC{
        private:
                vector<T> vec1;
                vector<T> vec2;

                set<T> st1;
                set<T> st2;

                vector<P> *ptr;
        private:
                template<vector<T>* vc>
                        void addVecVals(){
                                for(T i=0; i<10;i++)
                                {
                                        vc->push_back(i);
                                }
                        }

                template<set<T>* st>
                        void addStVals(){
                                for(T i=0; i<10;i++)
                                {
                                        st->insert(i);
                                }
                        }

                template<vector<T>* vc>
                        void printVecVals(){
                                for(typename vector<T>::iterator i=vc->begin(),
j=vc->end(); i!=j;++i)
                                {
                                        cout<<"val = "<<*i<<" , ";
                                }
                        }

                template<set<T>* st>
                        void printStVals(){
                                for(typename set<T>::iterator i=st->begin(),
j=st->end(); i!=j;++i)
                                {
                                        cout<<"val = "<<*i<<" , ";
                                }
                        }
        public:
                void add(int vecNum) {
                        switch(vecNum) {
                                case 0: //vecs.
                                        addVecVals<&vec1>();
                                        break;
                                case 1:
                                        addVecVals<&vec2>();
                                        break;
                                case 2: //sets
                                        addStVals<&st1>();
                                        break;
                                case 3:
                                        addStVals<&st2>();
                                        break;
                                default: break;
                        }
                }
                void print(int vecNum) {
                        switch(vecNum) {
                                case 0: //vecs.
                                        printVecVals<&vec1>();
                                        break;
                                case 1:
                                        printVecVals<&vec2>();
                                        break;
                                case 2: //sets
                                        printStVals<&st1>();
                                        break;
                                case 3:
                                        printStVals<&st2>();
                                        break;
                                default: break;
                        }
                }
};

int main(void) {
        MISC<uint64_t, double> m;
        m.add(0);
        m.add(1);
        m.add(2);
        m.add(3);
        return 0;
}


-- 
           Summary: g++ is giving error: parse error in template argument
                    list while using a c++ code.
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: raychaudhuri_amitava at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44906


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]