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 $
--
Summary: 'bus error' at runtime while passing a special struct to
a C++ member function
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jrr at concept dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: hppa2.0w-hp-hpux11.00
GCC host triplet: hppa2.0w-hp-hpux11.00
GCC target triplet: hppa2.0w-hp-hpux11.00
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18956