public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14262] New: Structure size computed wrong
@ 2004-02-23 20:14 rbh00 at utsglobal dot com
  2004-02-24  4:58 ` [Bug target/14262] " pinskia at gcc dot gnu dot org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: rbh00 at utsglobal dot com @ 2004-02-23 20:14 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2004-10-25  2:35 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-23 20:14 [Bug c/14262] New: Structure size computed wrong rbh00 at utsglobal dot com
2004-02-24  4:58 ` [Bug target/14262] " pinskia at gcc dot gnu dot org
2004-03-05 22:01 ` uweigand at gcc dot gnu dot org
2004-03-11 22:54 ` cvs-commit at gcc dot gnu dot org
2004-03-12  0:46 ` pinskia at gcc dot gnu dot org
2004-03-20  6:08 ` andreast at gcc dot gnu dot org
2004-03-20  6:57 ` andreast at gcc dot gnu dot org
2004-03-23 19:44 ` andreast at gcc dot gnu dot org
2004-04-09 18:55 ` geoffk at gcc dot gnu dot org
2004-04-09 19:33 ` andreast at gcc dot gnu dot org
2004-05-23 18:52 ` pinskia at gcc dot gnu dot org
2004-05-24  2:30 ` geoffk at gcc dot gnu dot org
2004-05-25 14:44 ` dalej at apple dot com
2004-05-26 14:15 ` dalej at apple dot com
2004-06-23 22:08 ` fjahanian at apple dot com
2004-06-24  6:30 ` andreast at gcc dot gnu dot org
2004-06-24 15:58 ` fjahanian at apple dot com
2004-06-26 18:39 ` cvs-commit at gcc dot gnu dot org
2004-06-28 15:13 ` uweigand at gcc dot gnu dot org
2004-07-02 19:58 ` dje at gcc dot gnu dot org
2004-07-05 16:01 ` uweigand at gcc dot gnu dot org
2004-07-05 16:14 ` pinskia at gcc dot gnu dot org
2004-09-23 18:17 ` pinskia at gcc dot gnu dot org
2004-10-25  2:35 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).