This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/9660: use of template keyword to specify templated method cause ICE
- From: maudouy at amadeus dot net
- To: gcc-gnats at gcc dot gnu dot org
- Date: 11 Feb 2003 10:28:39 -0000
- Subject: c++/9660: use of template keyword to specify templated method cause ICE
- Reply-to: maudouy at amadeus dot net
>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);
}