Bug 99236 - C++ code containing templated member function with same name as pure virtual member function result in link failure
C++ code containing templated member function with same name as pure virtual ...
Status: CLOSED UPSTREAM
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
9
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
http://gcc.gnu.org
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-07-16 08:55 EDT by Albert Strasheim
Modified: 2007-04-18 12:55 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-07-18 07:24:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
C++ source file that exhibits the bug (needs header file too) (215 bytes, text/plain)
2003-07-16 08:56 EDT, Albert Strasheim
no flags Details
C++ header file that exhibits the bug (also need source file) (782 bytes, text/plain)
2003-07-16 08:57 EDT, Albert Strasheim
no flags Details
Gzipped preprocessed file (87.34 KB, application/octet-stream)
2003-07-16 09:04 EDT, Albert Strasheim
no flags Details
Better code for exposing the bug (423 bytes, text/plain)
2003-07-17 10:46 EDT, Albert Strasheim
no flags Details

  None (edit)
Description Albert Strasheim 2003-07-16 08:55:20 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Description of problem:
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.

Version-Release number of selected component (if applicable):
gcc-3.2.2-5

How reproducible:
Always

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.
    

Actual Results:  Linking fails with an undefined reference to a pure virtual
function.

/tmp/ccxWgvhd.o(.text+0x21): In function `s3_streamable::unmarshal(char const*)':
: undefined reference to `s3_streamable::unpack(s3_buffer_base const&)'
collect2: ld returned 1 exit status


Expected Results:  Program should link successfully.

Additional info:

The same bug seems to exist in gcc 3.2-7.

Version info for this version of gcc:
[albert@foobar s3fc]$ 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)
Comment 1 Albert Strasheim 2003-07-16 08:56:37 EDT
Created attachment 92959 [details]
C++ source file that exhibits the bug (needs header file too)
Comment 2 Albert Strasheim 2003-07-16 08:57:00 EDT
Created attachment 92960 [details]
C++ header file that exhibits the bug (also need source file)
Comment 3 Albert Strasheim 2003-07-16 09:04:01 EDT
Created attachment 92961 [details]
Gzipped preprocessed file

Generated with g++ -save-temps -Wall -ansi -pedantic -I. -o boog boog.cc
Comment 4 Albert Strasheim 2003-07-17 10:46:32 EDT
Created attachment 92978 [details]
Better code for exposing the bug

Courtesy of Gerhard Esterhuizen <gesterhuizen@yahoo.com>
Comment 5 Albert Strasheim 2003-07-18 04:12:13 EDT
Also filed bug at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11567 because
jakub@redhat.com doesn't seem very responsive.
Comment 6 Albert Strasheim 2003-07-18 07:24:59 EDT
This bug has probably been fixed in 3.3.1. Check the gcc bugzilla at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11567

Note You need to log in before you can comment on or make changes to this bug.