Bug 699333 - Inconsistency in code generation for inline virtual functions depending on position of the "inline" keyword
Summary: Inconsistency in code generation for inline virtual functions depending on po...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gcc
Version: 6.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Jakub Jelinek
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks: 699334
TreeView+ depends on / blocked
 
Reported: 2011-04-25 07:40 UTC by Siddhesh Poyarekar
Modified: 2018-11-14 14:49 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 699334 (view as bug list)
Environment:
Last Closed: 2011-04-28 17:13:43 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 48759 0 None None None Never

Description Siddhesh Poyarekar 2011-04-25 07:40:14 UTC
Description:

The c+ parser seems to differentiate between inline virtual functions that have
the inline keyword only in the function definition as opposed to when it is
present in the declaration. When the inline keyword is only in the definition,
the function is flagged such that code is generated for it, which is not
correct.

How Reproducible:

Always:

Steps to Reproduce and Results:

[siddhesh@localhost ~]$ cat foo.ii
class A {
public:
    virtual void f();
};

inline void
A::f()
{
}
[siddhesh@localhost ~]$ g++ -c foo.ii
[siddhesh@localhost ~]$ objdump -dC foo.o

foo.o:     file format elf64-x86-64


Disassembly of section .text._ZN1A1fEv:

0000000000000000 <A::f()>:
   0:    55                       push   %rbp
   1:    48 89 e5                 mov    %rsp,%rbp
   4:    48 89 7d f8              mov    %rdi,-0x8(%rbp)
   8:    c9                       leaveq 
   9:    c3                       retq   

Expected Result:

The correct output, as shown when the inline keyword is present (at least) in
the declaration:

[siddhesh@localhost ~]$ cat foo.ii
class A {
public:
    virtual inline void f();
};

void
A::f()
{
}
[siddhesh@localhost ~]$ g++ -c foo.ii
[siddhesh@localhost ~]$ objdump -dC foo.o

foo.o:     file format elf64-x86-64

Additional Information:

Chapter 9.3 in the C++ standard says:

"an inline member function (whether static or non-static) may also be defined
outside of its class definition provided either its declaration in the class
definition or its definition outside of the class definition declares the
function as inline."

I could not find any exceptions to this rule for virtual functions.

Filed upstream as well:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48759

Comment 1 Jakub Jelinek 2011-04-28 17:13:43 UTC
Invalid, see the upstream PR for details.


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