This is the mail archive of the 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]

c++/9660: use of template keyword to specify templated method cause ICE

>Number:         9660
>Category:       c++
>Synopsis:       use of template keyword to specify templated method cause ICE
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 11 10:36:00 UTC 2003
>Release:        gcc 3.0.1
HP-UX B.11.11

the use of "template" keyword for template specialisation appearing in a postfix expression (ISO 14882 14.2.4) is causing an internal compiler error.

the attached file, compiled without options, reproduce the ICE.


an easy workaround is not to use the template keyword, it works in this case. but when using other compilers (like aCC on HP-UX) it is necessary.
Content-Type: text/plain; name="templateBug.cpp"
Content-Disposition: inline; filename="templateBug.cpp"

namespace TOTO {

    template <typename ObjectType,
    	  typename FirstArgumentType,
	  typename SecondArgumentType>
    create(FirstArgumentType & firstArg,
           SecondArgumentType & secondArg)
    	ObjectType & ref = *(new ObjectType(firstArg, secondArg));
    	return ref;

namespace FOO {

class A {
    int x_;
    int y_;
    A(int& x, int& y):x_(x),y_(y) {}	    

class B {
    A& getA(int a, int b)
        A& anA = TOTO::template create<A>(a,b);
        return anA;


int main() {
    FOO::B b;
    FOO::A& anA = b.getA(2,3);

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