Bug 37095 - [4.4 regression] Trouble with covariant return
Summary: [4.4 regression] Trouble with covariant return
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P1 normal
Target Milestone: 4.4.0
Assignee: Jakub Jelinek
URL:
Keywords: rejects-valid
: 37167 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-12 12:55 UTC by Volker Reichelt
Modified: 2008-09-10 08:32 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-08-22 15:26:26


Attachments
gcc44-pr37095.patch (699 bytes, patch)
2008-09-01 19:03 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2008-08-12 12:55:39 UTC
The following valid code snippet fails to compile on mainline when compiled
with "-O":

=======================================
struct A
{
  virtual A* foo();
};

struct B : virtual A
{
  virtual B* foo() { return 0; }
};

B b;
=======================================

bug.cc:11: error: 'B* *.LTHUNK1()' aliased to undefined symbol '_ZTch0_v0_n32_N1B3fooEv'
Comment 1 benjamin.redelings 2008-08-16 16:25:43 UTC
This bug has hit me as well. This blocks the popular "clone" idiom when using virtual base classes (which I use a lot of).

Might this change be a result of the indirect inlining patch?
Comment 2 Richard Biener 2008-08-22 15:26:25 UTC
This looks like a fallout from the unit-at-a-time changes.  The testcase
works for me with -O -fno-toplevel-reorder.

Honza, can you have a look here?
Comment 3 Jakub Jelinek 2008-09-01 13:50:40 UTC
The problem is that cgraph_node_for_asm assumes that once it has been called once, no new cgraph nodes will be created.  But that's not true, at least C++
lang_hooks.callgraph.emit_associated_thunks (decl) adds new cgraph nodes (for the thunks).  So, either cgraph_create_node should keep populating assembler_name_hash once that hash table is created, or there should be a cgraph function which can be called for the late cgraph nodes to get registered into
the assembler_name_hash.
Comment 4 Jakub Jelinek 2008-09-01 19:03:34 UTC
Created attachment 16184 [details]
gcc44-pr37095.patch

Patch I'm going to bootstrap now.
Comment 5 Jakub Jelinek 2008-09-02 10:34:58 UTC
Fixed.
Comment 6 Jakub Jelinek 2008-09-02 10:35:09 UTC
Subject: Bug 37095

Author: jakub
Date: Tue Sep  2 10:33:46 2008
New Revision: 139887

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139887
Log:
	PR tree-optimization/37095
	* cgraph.c (cgraph_node): When creating new cgraph node after
	assembler_name_hash has been populated, record it in the hash
	table.

	* g++.dg/inherit/thunk9.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/inherit/thunk9.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Jakub Jelinek 2008-09-10 08:32:33 UTC
*** Bug 37167 has been marked as a duplicate of this bug. ***