c++/765: Friend function can not have same name of a memeber function

xiao@dr.com xiao@dr.com
Thu Nov 9 21:56:00 GMT 2000


>Number:         765
>Category:       c++
>Synopsis:       Friend function can not have same name of a memeber function
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 09 21:56:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     xiao@dr.com
>Release:        gcc version 2.96 20000731 (Red Hat Linux 7.0)
>Organization:
>Environment:
i386-redhat-linux
>Description:
If a friend function uses the same name of a member function
(not the same signature), the compiler won't compile the program.

The error messages generated are as follows:

bug.cpp: In instantiation of `TForwardDeclarationBug<int>':
bug.cpp:64:   instantiated from here
bug.cpp:21: invalid use of undefined type `class 
TForwardDeclarationBug<int>'
bug.cpp:4: forward declaration of `class TForwardDeclarationBug<int>'
bug.cpp:21: Internal compiler error in tsubst_decl, at ../gcc/cp/pt.c:
5679
Please submit a full bug report.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.
>How-To-Repeat:
simply compile it with gcc:
gcc -c bug.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.ii"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.ii"

IyAxICJidWcuY3BwIgoKdGVtcGxhdGUgPGNsYXNzIFQ+CmNsYXNzIFRGb3J3YXJkRGVjbGFyYXRp
b25CdWcKewpwcml2YXRlOgogIFQgYV87CgpwdWJsaWM6CiAgVEZvcndhcmREZWNsYXJhdGlvbkJ1
Zyhjb25zdCBUICYgYSA9IFQoKSkgOiBhXyhhKSB7fTsKCiAgVEZvcndhcmREZWNsYXJhdGlvbkJ1
ZzxUPiBvcGVyYXRvciAtKCkKICB7CiAgICBURm9yd2FyZERlY2xhcmF0aW9uQnVnPFQ+IHJldChh
Xyk7CgogICAgcmV0LmFfID0gLXJldC5hXzsKCiAgICByZXR1cm4gKHJldCk7CiAgfQoKICBmcmll
bmQgVEZvcndhcmREZWNsYXJhdGlvbkJ1ZzxUPiBvcGVyYXRvciAtIDw+CiAgICAoY29uc3QgVEZv
cndhcmREZWNsYXJhdGlvbkJ1ZzxUPiAmIGxocywgY29uc3QgVEZvcndhcmREZWNsYXJhdGlvbkJ1
ZyA8VD4mIHJocyk7Cn07Cgp0ZW1wbGF0ZSA8Y2xhc3MgVD4KaW5saW5lClRGb3J3YXJkRGVjbGFy
YXRpb25CdWc8VD4gb3BlcmF0b3IgLShjb25zdCBURm9yd2FyZERlY2xhcmF0aW9uQnVnPFQ+ICYg
bGhzLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgVEZvcndhcmRE
ZWNsYXJhdGlvbkJ1ZzxUPiAmIHJocykKewogIHJldHVybiAobGhzLmFfIC0gcmhzLmFfKTsKfQoj
IDYyICJidWcuY3BwIgppbnQgbWFpbihpbnQsIGNoYXIgKiopCnsKICAgICAgICBURm9yd2FyZERl
Y2xhcmF0aW9uQnVnPGludD4gYSxiKDEpOwogICAgICAgIFRGb3J3YXJkRGVjbGFyYXRpb25CdWc8
aW50PiBjID0gYSAtIGI7CgogICAgICAgIHJldHVybiAoMCk7Cn0K


More information about the Gcc-bugs mailing list