Bug 39812 - gcc omits compilation of large inline virtual member function
Summary: gcc omits compilation of large inline virtual member function
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.1
Hardware: i386
OS: Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-05-09 08:10 UTC by j. alan eldridge
Modified: 2007-04-18 16:33 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-05-09 09:56:52 UTC
Embargoed:


Attachments (Terms of Use)
C++ source code to demonstrate gcc omitting compilation of large function (4.11 KB, text/plain)
2001-05-09 08:11 UTC, j. alan eldridge
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2001:082 0 high SHIPPED_LIVE New version of GCC 2.96-RH available fixing several bugs 2001-06-14 04:00:00 UTC

Description j. alan eldridge 2001-05-09 08:10:07 UTC
Description of Problem:

See attached source.

When compiling with -O2, a large virtual member function of a derived 
class that is defined as inlined in .cpp source, not header file, is not 
compiled, and an unresolved external reference is made instead.

Since the function is defined in the .cpp file (and is only called from 
within that same file), it won't get compiled elsewhere either. The end 
result is that the function is undefined and the program using the class 
cannot link.

How Reproducible:
[alane@wwweasel alane]$ rpm -q gcc
gcc-2.96-81
[alane@wwweasel alane]$ rpm -q gcc-c++
gcc-c++-2.96-81
[alane@wwweasel alane]$ g++ -O2 -c alzheimer.cpp
[alane@wwweasel alane]$ nm alzheimer.o
         U Oops_I_forgot_to_compile_this__9Mpegtoraw
00000000 ? __FRAME_BEGIN__
00000000 t gcc2_compiled.
00000000 T subbandsynthesis__9MpegtorawPfT1
[alane@wwweasel alane]$

Additional Information:

Removing the virtual function from either the parent class or the derived 
class (or making the function non-virtual) eliminates the error.

Compiling without -O2 also produces the correct result.

This code is from a package called avifile. I have stripped it down to 
the smallest bit that would still exhibit the problem. Although I have 
not tested it, it would seem likely that this problem does not present on 
gcc-2.95, as I believe that is what the package author is using.

Comment 1 j. alan eldridge 2001-05-09 08:11:39 UTC
Created attachment 17828 [details]
C++ source code to demonstrate gcc omitting compilation of large function

Comment 2 Jakub Jelinek 2001-05-09 09:56:47 UTC
See my analysis:
http://prak.org/pipermail/avifile/2001-May/001693.html
http://prak.org/pipermail/avifile/2001-May/001700.html
The issue is present in g++ 2.95.x as well, just in this case it throttles
inlining a little bit later. If you make the routine larger (I think twice
is enough, 4 times larger definitely is), it will fail the same way.
Avifile authors apparently don't care unfortunately, so I'll probably include
the patch I'm not too happy about.

Comment 3 Jakub Jelinek 2001-06-07 13:09:11 UTC
I've included the patch in gcc-c++-2.96-85.


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