Bug 11567 - C++ code containing templated member function with same name as pure virtual member function results in linking failure
Summary: C++ code containing templated member function with same name as pure virtual ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2.2
: P2 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-18 08:04 UTC by Albert Strasheim
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
First cut at code that shows the bug (source file) (161 bytes, text/plain)
2003-07-18 08:06 UTC, Albert Strasheim
Details
Code for showing bug (goes with boog.cc) (317 bytes, text/plain)
2003-07-18 08:06 UTC, Albert Strasheim
Details
Similar code for showing bug (253 bytes, text/plain)
2003-07-18 08:08 UTC, Albert Strasheim
Details
Preprocessed output for boog (87.34 KB, application/octet-stream)
2003-07-18 08:11 UTC, Albert Strasheim
Details
Preprocessed output for boog2 (248 bytes, application/octet-stream)
2003-07-18 08:20 UTC, Albert Strasheim
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Strasheim 2003-07-18 08:04:02 UTC
Attached C++ code contains a pure virtual function, unpack(), and a  a templated
function of the same name (but with different arguments). The presence of the
templated function causes linking to fail. Changing the name of the templated
function results in successful linking.

Implementing the unmarshal() (which calls the pure virtual function, which
should result in a call to unpack() implemented in the derived class) function
in the header also allows for successful linking, but I think this only hides
the bug.
Comment 1 Albert Strasheim 2003-07-18 08:05:06 UTC
Steps to Reproduce:
1. g++ -Wall -ansi -pedantic -I. -o boog boog.cc
2. Linking will fail with the message above.
3. Change "unpack" to something else (grep for FIXME).
4. Repeat 1. Linking succeeds.
Comment 2 Albert Strasheim 2003-07-18 08:06:17 UTC
Created attachment 4424 [details]
First cut at code that shows the bug (source file)
Comment 3 Albert Strasheim 2003-07-18 08:06:48 UTC
Created attachment 4425 [details]
Code for showing bug (goes with boog.cc)
Comment 4 Albert Strasheim 2003-07-18 08:08:55 UTC
Created attachment 4426 [details]
Similar code for showing bug

Courtesy of Gerhard Esterhuizen <gesterhuizen@yahoo.com>.

Nicely shows the "workaround" of implementing the calling function in the
header (but this doesn't always seem to work in my experience).
Comment 5 Albert Strasheim 2003-07-18 08:10:40 UTC
Also filed bug at https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=99236 but
jakub@redhat.com didn't seem very responsive.

Version info from gcc -v:

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Same bug seems to exist in gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7).
Comment 6 Albert Strasheim 2003-07-18 08:11:37 UTC
Created attachment 4427 [details]
Preprocessed output for boog
Comment 7 Albert Strasheim 2003-07-18 08:20:41 UTC
Created attachment 4428 [details]
Preprocessed output for boog2
Comment 8 Andrew Pinski 2003-07-18 11:11:10 UTC
I can reproduce this on 3.2.3 but in 3.3.1 (20030707), gcc is already fixed.
It is most likely fixed in 3.3 but for sure it is fixed in 3.3.1 which will be release in the next 
two weeks.