Bug 37473 - typedef results in wrong function call linkage
Summary: typedef results in wrong function call linkage
Status: RESOLVED DUPLICATE of bug 7221
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-09-11 02:43 UTC by Alan Modra
Modified: 2008-09-16 07:02 UTC (History)
8 users (show)

See Also:
Host:
Target: x86_64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2008-09-11 02:43:01 UTC
The following testcase compiled with -O -fPIC results in a non-PLT call to A::check.  On x86_64 that means an R_X86_64_PC32 reloc, which the linker later correctly complains about if we are building a shared library.  Curiously, if either or both of the typedefs are removed, you get the code I'd expect.

typedef struct
{
  int check ();
} A;

typedef struct
{
  A a;
  int validate ();
private:
  int check ();
} B;

int
B::check ()
{
  return a.check ();
}

int
B::validate ()
{
  return check ();
}

int
doit ()
{
  B b;
  return b.validate ();
}
Comment 1 Andrew Pinski 2008-09-14 04:46:11 UTC
Lets see oh one of the old of known bugs 7221 :).

*** This bug has been marked as a duplicate of 7221 ***