Bug 39812 - gcc omits compilation of large inline virtual member function
gcc omits compilation of large inline virtual member function
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-05-09 04:10 EDT by j. alan eldridge
Modified: 2007-04-18 12:33 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-05-09 05:56:52 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 code to demonstrate gcc omitting compilation of large function (4.11 KB, text/plain)
2001-05-09 04:11 EDT, j. alan eldridge
no flags Details

  None (edit)
Description j. alan eldridge 2001-05-09 04:10:07 EDT
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 04:11:39 EDT
Created attachment 17828 [details]
C++ source code to demonstrate gcc omitting compilation of large function
Comment 2 Jakub Jelinek 2001-05-09 05:56:47 EDT
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 09:09:11 EDT
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.