c++/1774: parse error with method template of class template
bgreen@nas.nasa.gov
bgreen@nas.nasa.gov
Sun Apr 1 00:00:00 GMT 2001
>Number: 1774
>Category: c++
>Synopsis: parse error with method template of class template
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Thu Jan 25 17:56:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Bryan Green
>Release: gcc version 2.96 20000731 and 2.97 20010120 (experimental)
>Organization:
>Environment:
Linux 2.2.16-22smp #1 SMP i686 unknown
and codesourcery online submission
>Description:
g++ gets a parse error for valid code, under the following
set of precise conditions:
1) a method template is defined in a templated base class
2) a class template derives from the base class, the base
class being given the same template parameters as specified
for the derived class, i.e.:
template <int Dim>
class Test : public TestBase<Dim>
3) inside the derived class, a call is made to the method
template, using the func<...>(...) syntax for choosing a
specialization, i.e.: 'int sz = subsize<2>();'
This call generates a parse error.
$ g++ -c templbug.C
templbug.C: In method `int Test<Dim>::size2 () const':
templbug.C:16: parse error before `)'
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="templbug.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="templbug.C"
CnRlbXBsYXRlIDxpbnQgRGltPgpjbGFzcyBUZXN0QmFzZQp7CnB1YmxpYzoKICAgIHRlbXBsYXRl
IDxpbnQgU0RpbT4KICAgIGludCBzdWJzaXplKCkgY29uc3QgeyByZXR1cm4gRGltLVNEaW07IH0K
ICAgIGludCBzaXplKCkgY29uc3QgeyByZXR1cm4gc3Vic2l6ZTxEaW0+KCk7IH0KfTsKCnRlbXBs
YXRlIDxpbnQgRGltPgpjbGFzcyBUZXN0IDogcHVibGljIFRlc3RCYXNlPERpbT4KewpwdWJsaWM6
CiAgICBpbnQgc2l6ZTIoKSBjb25zdCB7CiAgICAgICAgaW50IHN6ID0gc3Vic2l6ZTxEaW0+KCk7
CiAgICAgICAgcmV0dXJuIHN6OwogICAgfQp9OwoKdm9pZCBmKCkKewogICAgVGVzdDwyPiB0Owog
ICAgaW50IGk7CiAgICBpID0gdC5zaXplKCk7CiAgICBpID0gdC5zdWJzaXplPDI+KCk7CiAgICBp
ID0gdC5zaXplMigpOwp9Cgo=
More information about the Gcc-prs
mailing list