c++/7638: inline friend in template class produces strange error msg
tkarkanis@aw.sgi.com
tkarkanis@aw.sgi.com
Mon Aug 19 15:06:00 GMT 2002
>Number: 7638
>Category: c++
>Synopsis: inline friend in template class produces strange error msg
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Aug 19 14:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: tkarkanis@aw.sgi.com
>Release: 3.1
>Organization:
>Environment:
Red Hat Linux 7.3, IA32
>Description:
The compiler rejects the input in the attached file. I'm
not sure that the input is legal (because it's kind of
strange to have an inline definition of a friend function
in a template class). I assume it is legal because every
other compiler that I tried (IRIX, Solaris, HP-UX) accepts
the input.
Even if the input is correctly
rejected, the error message is incorrect because the friend
function is neither virtual nor abstract.
lnx-stdbld:~/tmp> g++3 -c ostream.cpp
ostream.cpp:19: cannot declare parameter `arg' to be of type `Complex<Float>'
ostream.cpp:19: because the following virtual functions are abstract:
ostream.cpp:7: ostream& operator<<(ostream&, const Complex<Float>&)
>How-To-Repeat:
g++3 -c ostream.cpp
>Fix:
A workaround is to take the friend function definition out
of the class definition.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="ostream.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ostream.cpp"
Y2xhc3Mgb3N0cmVhbTsKCnRlbXBsYXRlPHR5cGVuYW1lIEZsb2F0PgpjbGFzcyBDb21wbGV4CnsK
ICAgIGZyaWVuZCBvc3RyZWFtJiBvcGVyYXRvcjw8KCBvc3RyZWFtJiBvcywgY29uc3QgQ29tcGxl
eCYgYyApCiAgICAgICAgeyByZXR1cm4gb3M7IH0KICAgIAogICAgRmxvYXQgbV9yZSwgbV9pbTsK
cHVibGljOgogICAgCiAgICBDb21wbGV4JiBvcGVyYXRvcis9KCBDb21wbGV4ICk7Cn07CgoKdGVt
cGxhdGU8dHlwZW5hbWUgRmxvYXQ+CmlubGluZSBDb21wbGV4PEZsb2F0PiYKQ29tcGxleDxGbG9h
dD46Om9wZXJhdG9yKz0oIENvbXBsZXggYXJnICkKewogICAgcmV0dXJuICp0aGlzOwp9Cg==
More information about the Gcc-prs
mailing list