Wrong code is generated causing bus error in test(gdb): (gdb) r Program received signal SIGBUS, Bus error. 0x00002b48 in bar () (gdb) disass Dump of assembler code for function bar: 0x00002b40 <+0>: addil L%-800,dp,r1 0x00002b44 <+4>: ldo 780(r1),r1 => 0x00002b48 <+8>: ldw 1(r1),ret0 0x00002b4c <+12>: extrw,u ret0,15,16,r19 0x00002b50 <+16>: sth r19,2(r1) 0x00002b54 <+20>: sth ret0,4(r1) 0x00002b58 <+24>: ldi 2e,ret0 0x00002b5c <+28>: bv r0(rp) 0x00002b60 <+32>: stb ret0,1(r1)
Register r1 points to str which has 4-byte alignment. So, the memory address for the ldw instruction is misaligned. The test would also fail on linux if the unaligned handler was disabled. We have the following for function bar after coalescing: bar () { unsigned int D.1980; # BLOCK 2 freq:10000 # PRED: ENTRY [100.0%] (fallthru,exec) D.1980_3 = MEM[(char * {ref-all})&str + 1B]; MEM[(char * {ref-all})&str + 2B] = D.1980_3; str[1] = 46; return; # SUCC: EXIT [100.0%] } -- Summary: FAIL: gcc.dg/pr35258.c execution test Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: danglin at gcc dot gnu dot org GCC build triplet: hppa*-*-hpux* GCC host triplet: hppa*-*-hpux* GCC target triplet: hppa*-*-hpux* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44903