Bug 36107 - weak constructor produces invalid asm
Summary: weak constructor produces invalid asm
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-05-02 11:55 UTC by William FINK
Modified: 2012-10-11 14:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.5.4, 4.7.0, 4.8.0
Known to fail: 4.1.1, 4.3.0, 4.4.0
Last reconfirmed: 2008-05-05 05:10:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description William FINK 2008-05-02 11:55:58 UTC
When using __attribute__((weak)) on a constructor, the produced assembly file contains an extra *INTERNAL* on the constructor declaration line.

- Here is my test code:

class Test {
  public:
  Test() __attribute__((weak));
};

int test() {
  Test test;
}

- The compilation output:
$ g++ test.cc 
/tmp/cchKRpYD.s: Assembler messages:
/tmp/cchKRpYD.s:22: Error: junk at end of line, first unrecognized character is `*'

- The corresponding asm line 22:
	.weak	_ZN4TestC1Ev *INTERNAL*

I have tried this with and it does not work for:
- gcc (GCC) 4.3.0 (compiled from sources)
- gcc-4.2 (GCC) 4.2.1 (Ubuntu 4.2.1-5ubuntu4)
- gcc-4.1 (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)

It works without problems with:
- gcc-3.4 (GCC) 3.4.6 (Ubuntu 3.4.6-6ubuntu2)

If I manually remove the '*INTERNAL*' from the asm file, it compiles correctly.

I found a similar old bug (6418) from the GCC3.04 version
Comment 1 Andrew Pinski 2008-05-05 05:10:15 UTC
Even if the code assembled for 3.3.6 or 3.4.x, the weak reference was not being emitted.  So this is not a regression really.
Comment 2 Paolo Carlini 2012-10-11 14:14:11 UTC
Fixed a looong time ago, 4_5-branch is fine. I'm adding the testcase and closing the PR.
Comment 3 paolo@gcc.gnu.org 2012-10-11 14:38:00 UTC
Author: paolo
Date: Thu Oct 11 14:37:44 2012
New Revision: 192361

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192361
Log:
2012-10-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/36107
	* g++.dg/ext/weak5.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/ext/weak5.C
Modified:
    trunk/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2012-10-11 14:41:41 UTC
Done.