Article View: gnu.gcc.bug
Article #625Long Long Int and Structures with Bitfields
From: Mark Davis
Date: Mon, 25 Sep 1989 14:55
Date: Mon, 25 Sep 1989 14:55
64 lines
2567 bytes
2567 bytes
Fields in structures (with bit sizes specified) are not correctly
assigned to long long ints. The high order word of the target
containts some unpredictable value.
==================== Source Listing =============================
clocs% cat s2.c
main()
{
struct this
{
short int si;
unsigned int that:24;
unsigned int them:24;
} direct;
long long int lli;
int ii;
ii=-1;
lli = ii;
printf("ii=%d. lli=%d/%d\n",ii,lli);
direct.that=5;
lli=direct.that;
ii=direct.that;
printf("direct.that=%d, ii=%d, lli=%d/%d.\n",direct.that,ii,lli);
}
=================== Program Output ==============================
clocs% s2
ii=-1. lli=-1/-1
direct.that=5, ii=5, lli=17/5.
/* Comment:
* If lli is not set first (to demonstate that int assignments
* work) the output is correct. Other changes to the program also
* change the resulting incorrect answer.
*/
================== Output of Compile ============================
clocs% make s2
gcc -g -v s2.c -o s2
gcc version 1.36
/unc/davis/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 s2.c /usr/tmp/cca18737.cpp
GNU CPP version 1.36
/unc/davis/lib/gcc-cc1 /usr/tmp/cca18737.cpp -quiet -dumpbase s2.c -g -version -o /usr/tmp/cca18737.s
GNU C version 1.36 (68k, MIT syntax) compiled by CC.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
as -mc68020 -o s2.o /usr/tmp/cca18737.s
ld -o s2 /lib/crt0.o /lib/Mcrt1.o s2.o /unc/davis/lib/gcc-gnulib -lg -lc
================ Compiler Build History =========================
GCC 1.36
clocs% config.gcc sun3
Linked `config.h' to `./config/xm-m68k.h'.
Linked `tm.h' to `./config/tm-sun3os3.h'.
Linked `md' to `./config/m68k.md'.
Linked `aux-output.c' to `./config/out-m68k.c'.
Links are now set up for use with a sun3.
Then, I edited config/tm-m68k.h to define WORDS_BIG_ENDIAN.
[and edited Makefile to change bin directory, etc.]
compiled and run on a Sun 3/60 running Sun UNIX 4.2 Release 3.5
Hope this helps - Mark (davis@cs.unc.edu or uunet!mcnc!davis) (919)962-1739
Technical Details
Message-ID:
<8909251455.AA18791@clocs.cs.unc.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!gem.mps.ohio-state.edu!pacific.mps.ohio-state.edu!tut.cis.ohio-state.edu!cs.unc.edu!davisShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!gem.mps.ohio-state.edu!pacific.mps.ohio-state.edu!tut.cis.ohio-state.edu!cs.unc.edu!davis From: davis@cs.unc.edu (Mark Davis) Newsgroups: gnu.gcc.bug Subject: Long Long Int and Structures with Bitfields Message-ID: <8909251455.AA18791@clocs.cs.unc.edu> Date: 25 Sep 89 14:55:09 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 64