This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/63896] New: g++.dg/ipa/devirt-7.C produces code that trips the darwin linker
- From: "fxcoudert at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 15 Nov 2014 18:15:54 +0000
- Subject: [Bug c++/63896] New: g++.dg/ipa/devirt-7.C produces code that trips the darwin linker
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63896
Bug ID: 63896
Summary: g++.dg/ipa/devirt-7.C produces code that trips the
darwin linker
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fxcoudert at gcc dot gnu.org
g++.dg/ipa/devirt-7.C fails on x86_64-apple-darwin14: it generates code that
makes the darwin linker error out. Minimal reproducer is:
------------------------
class Distraction
{
virtual float bar ();
};
class A
{
public:
virtual void foo ();
};
class B : Distraction, A
{
public:
void __attribute__ ((noinline)) middleman () { foo(); }
};
void A::foo ()
{
}
extern int get_input ();
int main (void)
{
class B b;
for (int i = 0; i < get_input(); i++)
b.middleman();
}
------------------------
Compiling it with "./bin/g++ -W -Wall -O3 devirt-7.C", the linker aborts
uglily:
0 0x10d4fcb51 __assert_rtn + 144
1 0x10d524c99
mach_o::relocatable::Parser<x86_64>::parse(mach_o::relocatable::ParserOptions
const&) + 3269
2 0x10d5080fd mach_o::relocatable::Parser<x86_64>::parse(unsigned char
const*, unsigned long long, char const*, long, ld::File::Ordinal,
mach_o::relocatable::ParserOptions const&) + 375
3 0x10d54b8cd ld::tool::InputFiles::makeFile(Options::FileInfo const&, bool)
+ 705
4 0x10d54d7ec ld::tool::InputFiles::parseWorkerThread() + 496
5 0x7fff89c5f2fc _pthread_body + 131
6 0x7fff89c5f279 _pthread_body + 0
A linker snapshot was created at:
/tmp/a.out-2014-10-15-191218.ld-snapshot
ld: Assertion failed: (cfiStartsArray[i] != cfiStartsArray[i-1]), function
parse, file
/SourceCache/ld64/ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp, line
1745.
collect2: error: ld returned 1 exit status
Here is a diff between the assembler code emitted by gcc 4.9.2 (which doesn't
trigger the ld issue), and that of trunk gcc:
--- good.s 2014-11-15 18:58:24.000000000 +0100
+++ bad.s 2014-11-15 18:58:14.000000000 +0100
@@ -23,7 +23,6 @@ LHOTB1:
.align 4,0x90
__ZN1B9middlemanEv.constprop.0:
LFB12:
- ret
LFE12:
.section __TEXT,__text_cold,regular,pure_instructions
LCOLDE1:
@@ -37,19 +36,16 @@ LHOTB2:
.globl _main
_main:
LFB2:
- pushq %rbx
+ subq $24, %rsp
LCFI0:
- xorl %ebx, %ebx
- jmp L4
- .align 4
-L5:
- addl $1, %ebx
-L4:
call __Z9get_inputv
- cmpl %eax, %ebx
- jl L5
+ testl %eax, %eax
+ jle L4
+ movq %rsp, %rdi
+ call __ZN1B9middlemanEv.constprop.0
+L4:
xorl %eax, %eax
- popq %rbx
+ addq $24, %rsp
LCFI1:
ret
LFE2:
@@ -63,14 +59,19 @@ __ZTS1A:
.ascii "1A\0"
.globl __ZTI1A
.const_data
- .align 4
+ .align 3
__ZTI1A:
.quad __ZTVN10__cxxabiv117__class_type_infoE+16
.quad __ZTS1A
+ .globl __ZTS1B
+ .weak_definition __ZTS1B
+ .section __TEXT,__const_coal,coalesced
+__ZTS1B:
+ .ascii "1B\0"
.globl __ZTI1B
.weak_definition __ZTI1B
.section __DATA,__const_coal,coalesced
- .align 5
+ .align 3
__ZTI1B:
.quad __ZTVN10__cxxabiv121__vmi_class_type_infoE+16
.quad __ZTS1B
@@ -80,15 +81,9 @@ __ZTI1B:
.quad 0
.quad __ZTI1A
.quad 2048
- .globl __ZTS1B
- .weak_definition __ZTS1B
- .section __TEXT,__const_coal,coalesced
-__ZTS1B:
- .ascii "1B\0"
.globl __ZTV1B
.weak_definition __ZTV1B
- .section __DATA,__const_coal,coalesced
- .align 5
+ .align 3
__ZTV1B:
.quad 0
.quad __ZTI1B
@@ -98,7 +93,7 @@ __ZTV1B:
.quad __ZN1A3fooEv
.globl __ZTV1A
.const_data
- .align 4
+ .align 3
__ZTV1A:
.quad 0
.quad __ZTI1A
@@ -158,9 +153,7 @@ LASFDE5:
.set L$set$7,LCFI0-LFB2
.long L$set$7
.byte 0xe
- .byte 0x10
- .byte 0x83
- .byte 0x2
+ .byte 0x20
.byte 0x4
.set L$set$8,LCFI1-LCFI0
.long L$set$8