This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/14262] New: Structure size computed wrong
- From: "rbh00 at utsglobal dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Feb 2004 20:14:37 -0000
- Subject: [Bug c/14262] New: Structure size computed wrong
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Here is the recipe for reproducing this problem. Reproduce it on a gcc built
for the 64-bit s390x architecture. I am submitting this bug report at the
request of Ulrich Weigand, to whom I sent the email below.
Ulrich asked that if the code worked correctly on SuSE7, gcc 2.95, that I should
mark this bug as a regression,. But that was a 31-bit system and the code still
works correctly on (31-bit) s390 in gcc 3.2; it appears to be only a 64-bit problem.
Here's the code that demonstrates the problem:
Hi, Ulrich
Here is a program that doesn't execute correctly on Linux SuSE SLES8 for s390x:
/*
* Reproduce the bad compiler code for tpsilo_.c
*/
#define SIGNED signed
typedef SIGNED char ACS;
typedef SIGNED char LSM;
typedef char PANEL;
typedef char DRIVE;
typedef struct {
ACS acs;
LSM lsm;
} LSMID;
typedef struct {
LSMID lsm_id;
PANEL panel;
} PANELID;
typedef struct {
PANELID panel_id;
DRIVE drive;
} DRIVEID;
void sub(DRIVEID);
main()
{
DRIVEID driveid;
printf("Sizeof DRIVEID is %d\n", sizeof(DRIVEID));
driveid.drive = 1;
driveid.panel_id.panel = 9;
driveid.panel_id.lsm_id.lsm = 0;
driveid.panel_id.lsm_id.acs = 0;
printf("main() sent this driveid:\n");
printf("\tacs = %d\n", driveid.panel_id.lsm_id.acs);
printf("\tlsm = %d\n", driveid.panel_id.lsm_id.lsm);
printf("\tpanel = %d\n", driveid.panel_id.panel);
printf("\tdrive = %d\n", driveid.drive);
printf("The size of driveid is %d\n", sizeof driveid);
sub(driveid);
}
void
sub(DRIVEID did)
{
printf("sub() received this driveid:\n");
printf("\tacs = %d\n", did.panel_id.lsm_id.acs);
printf("\tlsm = %d\n", did.panel_id.lsm_id.lsm);
printf("\tpanel = %d\n", did.panel_id.panel);
printf("\tdrive = %d\n", did.drive);
}
Apparently the fault is in the caller code: an "lg" is generated, though the
argument structure is 4 bytes long. Here is the output of gcc -v:
Reading specs from /usr/lib64/gcc-lib/s390x-suse-linux/3.2/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man
--libdir=/usr/lib64 --enable-languages=c,c++,f77,objc,java --enable-libgcj
--with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib
--enable-shared --enable-__cxa_atexit s390x-suse-linux
Thread model: posix
gcc version 3.2
[snip]
Richard Hitt rbh00@utsglobal.com
--
Summary: Structure size computed wrong
Product: gcc
Version: 3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rbh00 at utsglobal dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: s390x-suse-linux
GCC host triplet: s390x-suse-linux
GCC target triplet: s390x-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14262