The following simple C++ program dies with a 'bus error' on PA/HPUX: struct WrongPadding { unsigned short one, two, three; /* unsigned short padding_dummy; --> BUS ERROR w/o this padding member */ }; struct A { public: void foo(int a, int b, struct WrongPadding bar) {} }; int main(int argc, char* argv[]) { A obj; struct WrongPadding bar; obj.foo(0, 0, bar); // --> Bus Error when calling this member function return 0; } ---- To reproduce: ------------- $ g++ -Wall buserror.cpp -o buserror $ ./buserror Bus error (core dumped) ---- I suspect a problem with alignment / struct padding when calling the member function foo. As a work-around, I added an additional 'unsigned short' member to the struct. The 64-bit port (target hppa64-hp-hpux11.00) of gcc-3.3.3 does not have this problem. I wasn't able to reproduce something similar with C (instead of C++). ---- Software version information follows: ------------------------------------- * GCC-3.3.3 was configured with: $ g++ -v Reading specs from /usr/local/lib/gcc-lib/hppa2.0w-hp-hpux11.00/3.3.3/specs Configured with: /extra/src/gcc-3.3.3/configure --enable-languages=c,c++ --with-gnu-as --with-as=/usr/local/32bit/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls Thread model: single gcc version 3.3.3 * HP Linker version: (recent linker patch applied) $ /usr/ccs/bin/ld -V 92453-07 linker command s800.sgs ld PA64 B.11.41 REL 040808 /usr/ccs/bin/ld: 92453-07 linker linker ld B.11.41 040911 * GNU assembler version: (compiled from binutils-2.14) $ /usr/local/32bit/bin/as -v GNU assembler version 2.14 (hppa2.0w-hp-hpux11.00) using BFD version 2.14 20030612 * binutils 2.14 was built by commercial ANSI-C compiler: $ what /opt/ansic/bin/cc /opt/ansic/bin/cc: $Revision: 92453-07 linker linker crt0.o B.11.16.01 030316 $ LINT B.11.11.08 CXREF B.11.11.08 HP92453-01 B.11.11.08 HP C Compiler $ PATCH/11.00:PHCO_27774 Oct 3 2002 09:45:59 $
I can reproduce this 3.3.3 and 3.4.3. However, 4.0.0 doesn't have the problem. While this problem may be target specific (ie., a big endian target with downward padding for structures), I don't believe this is actually a target specific problem. The 3.4.3 code generated in main to call "foo" looks like this: stw %r2,-20(%r30) copy %r3,%r1 copy %r30,%r3 stwm %r1,128(%r30) stw %r3,-4(%r30) stw %r26,-36(%r3) stw %r25,-40(%r3) ldw 16(%r3),%r19 stw %r19,-54(%r30) ldh 20(%r3),%r19 sth %r19,-50(%r30) ldo 8(%r3),%r26 ldi 0,%r25 ldi 0,%r24 .CALL ARGW0=GR,ARGW1=GR,ARGW2=GR bl _ZN1A3fooEii12WrongPadding,%r2 nop The "stw %r19,-54(%r30)" insn is a misaligned store and causes the problem. I also can't duplicate the problem in C. In that case, half-word loads and stores are used for storing the struct to the stack for the call. Thus, I suspect that this actually is a C++ bug.
Confirmed.
(In reply to comment #1) > I can reproduce this 3.3.3 and 3.4.3. However, 4.0.0 doesn't have the > problem. Are you working on this? It lools like the bug has been there for a while. I'm inclined to postponed untill GCC 3.4.6 -- Gaby
Subject: Re: [3.4 only] [hppa] 'bus error' at runtime while passing a special struct to a C++ member function > Are you working on this? It lools like the bug has been there for a while. > I'm inclined to postponed untill GCC 3.4.6 No. 3.4.6 is a more reasonable target. Dave
(In reply to comment #4) > Subject: Re: [3.4 only] [hppa] 'bus error' at runtime while passing a special > struct to a C++ member function > > > Are you working on this? It lools like the bug has been there for a while. > > I'm inclined to postponed untill GCC 3.4.6 > > No. 3.4.6 is a more reasonable target. OK, so be it. -- Gaby
won't fix for 3.4.6