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

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
>Closed-Date:
>Last-Modified:
>Originator:     maudouy@amadeus.net
>Release:        gcc 3.0.1
>Organization:
>Environment:
HP-UX B.11.11
>Description:

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.

>How-To-Repeat:

>Fix:
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.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="templateBug.cpp"
Content-Disposition: inline; filename="templateBug.cpp"


namespace TOTO {

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

namespace FOO {

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


class B {
public:
    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]