c++/9938: bug with nested friend of a nested class of a templated class
jasonkim@cis.upenn.edu
jasonkim@cis.upenn.edu
Tue Mar 4 12:36:00 GMT 2003
>Number: 9938
>Category: c++
>Synopsis: bug with nested friend of a nested class of a templated class
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Mar 04 12:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: jasonkim@cis.upenn.edu
>Release: 3.2.2
>Organization:
>Environment:
Linux (Redhat 7.2)
>Description:
A templated container class defines a nested class (i.e. iterator), which itself defines an inline friend operator function.
gcc 3.2.2 complains that the defined friend operator of the nested class is an abstract method of the nested class!
This results in the inability to instantiate the nested class.
Note that gcc 2.95.3 correctly compiles the supplied code snippet.
>How-To-Repeat:
The problem can be seen by simply compiling the supplied code snippet.
g++ -c gcc32tst.cc
>Fix:
move the definition of the offending friend function out of the body of nested class and supply -Wno-non-template-friend
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gcc32tst.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gcc32tst.cc"
IAp0ZW1wbGF0ZSA8Y2xhc3MgVCwgY2xhc3MgWT4gCmNsYXNzIGNvbnRhaW5lciAgCnsgCnB1Ymxp
YzoKICB0eXBlZGVmIGNvbnRhaW5lcjxULFk+IHRoaXNjbGFzczsKICAKICBUICphcnA7CiAgVCAq
b2k7CiAgCiAgY2xhc3MgaXRlciB7IAogIHByb3RlY3RlZDoKICAgIHRoaXNjbGFzcyAqcDsKICAg
IGludCBpZHg7CiAgcHVibGljOiAgICAKICAgIHZpcnR1YWwgaW5saW5lIGludCBrZXkoKSBjb25z
dCB7IHJldHVybiBpZHg7IH0KICAgIGZyaWVuZCBib29sIG9wZXJhdG9yPT0oY29uc3QgaXRlciAm
eCwgY29uc3QgaXRlciAmeSkgeyAKICAgICAgcmV0dXJuIFRSVUU7CiAgICB9IAogIH07IAoKICBj
bGFzcyBjb25zdF9pdGVyIHsgCiAgcHJvdGVjdGVkOgogICAgY29uc3QgdGhpc2NsYXNzICpwOwog
ICAgaW50IGlkeDsKICBwdWJsaWM6CiAgICB2aXJ0dWFsIGlubGluZSBpbnQga2V5KCkgY29uc3Qg
eyByZXR1cm4gaWR4OyB9CiAgICBmcmllbmQgYm9vbCBvcGVyYXRvcj09KGNvbnN0IGNvbnN0X2l0
ZXIgJngsIGNvbnN0IGNvbnN0X2l0ZXIgJnkpIHsgCiAgICAgIHJldHVybiBUUlVFOwogICAgfSAK
ICB9OwoKICB2aXJ0dWFsIGlubGluZSBib29sIGluc2VydChjb25zdF9pdGVyIGl0LCBUICppdGVt
KSB7CiAgICBhcnBbaXQua2V5KCldID0gKml0ZW07CiAgfQogIAp9OyAKCmludCBtYWluKCkKewog
IGNvbnRhaW5lcjxpbnQsdm9pZD4gYzsKICBjb250YWluZXI8ZmxvYXQsdm9pZD4gZDsKICBjb250
YWluZXI8Y29udGFpbmVyPGludCx2b2lkPix2b2lkID4gZTsKICAKfQo=
More information about the Gcc-prs
mailing list