Bug 99236

Summary: C++ code containing templated member function with same name as pure virtual member function result in link failure
Product: [Retired] Red Hat Linux Reporter: Albert Strasheim <albert>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
URL: http://gcc.gnu.org
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-07-18 11:24:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
C++ source file that exhibits the bug (needs header file too)
none
C++ header file that exhibits the bug (also need source file)
none
Gzipped preprocessed file
none
Better code for exposing the bug none

Description Albert Strasheim 2003-07-16 12:55:20 UTC
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 12:56:37 UTC
Created attachment 92959 [details]
C++ source file that exhibits the bug (needs header file too)

Comment 2 Albert Strasheim 2003-07-16 12:57:00 UTC
Created attachment 92960 [details]
C++ header file that exhibits the bug (also need source file)

Comment 3 Albert Strasheim 2003-07-16 13:04:01 UTC
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 14:46:32 UTC
Created attachment 92978 [details]
Better code for exposing the bug

Courtesy of Gerhard Esterhuizen <gesterhuizen>

Comment 5 Albert Strasheim 2003-07-18 08:12:13 UTC
Also filed bug at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11567 because
jakub doesn't seem very responsive.

Comment 6 Albert Strasheim 2003-07-18 11:24:59 UTC
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