🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #460

Obscure bug involving bit fields, asm and ({ })

#460
From: Bruno Verlyck
Date: Thu, 13 Jul 1989 13:31
74 lines
2427 bytes
Compiler: GCC 1.35
System:   SunOS Release 4.0_Export, or Sun Release 3.5EXPORT
Machine:  Sun 3/mc68020
Verbose:
	  gcc -v -S bug.i
	  gcc version 1.35
	   /usr/local/lib/gcc-cc1 bug.i -quiet -version -o bug.s
	  GNU C version 1.35 (68k, MIT syntax) compiled by GNU C version 1.35.

 There is no asm generated for the flagged line in the following
source.  Note that if the (useless) `({ })' around the asm construct
is removed, the bug disappears. (BTW, I don't know *why* it was
written like this.)

Source:

typedef struct {
  unsigned char address_base;
  unsigned char address_mask;
  unsigned int enable	       : 1;
  unsigned int unused0	       : 4;
  unsigned int cache_inhibit   : 1;
  unsigned int read_write      : 1;
  unsigned int read_write_mask : 1;
  unsigned int unused1         : 1;
  unsigned int func_code_base  : 3;
  unsigned int unused2         : 1;
  unsigned int func_code_mask  : 3;
} Transparency_Reg;

void
main  ()
{
  Transparency_Reg ttr;

  ttr.address_mask = 0;
  ttr.address_base = 0x10000000  >> 24 ;
  ttr.enable = 1;
  ttr.cache_inhibit = 0;
  ttr.read_write = 0;
  ttr.read_write_mask = 1;
  ttr.func_code_base = 0;
  ttr.func_code_mask = 7;	<---------------- this line is `ignored'
  ({ asm ("pmove %0,tt0" : : "m" (*(&ttr))); }) ;
}

Generated code:

#NO_APP
gcc_compiled.:
.text
	.even
.globl _main
_main:
	link a6,#-4
	clrb a6@(-3)		#   ttr.address_mask = 0;
	moveb #16,a6@(-4)	#   ttr.address_base = 0x10000000  >> 24 ;
	movel a6@(-4),d0
	orw #32768,d0
	movel d0,a6@(-4)	#   ttr.enable = 1;
	andw #64511,d0
	movel d0,a6@(-4)	#   ttr.cache_inhibit = 0;
	andw #65023,d0
	movel d0,a6@(-4)	#   ttr.read_write = 0;
	orw #256,d0
	movel d0,a6@(-4)	#   ttr.read_write_mask = 1;
	bfclr a6@(-4){#25:#3}	#   ttr.func_code_base = 0;
	#   ttr.func_code_mask = 7; ???
#APP
	pmove a6@(-4),tt0	#   ({ asm ("pmove %0,tt0" : : "m" (*(&ttr))); }) ;
#NO_APP
	unlk a6
	rts
Technical Details
Message-ID: <8907131331.AA02113@gipsi-future.gipsi.fr>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!future.gipsi.fr!bruno

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!future.gipsi.fr!bruno
From: bruno@future.gipsi.fr (Bruno Verlyck)
Newsgroups: gnu.gcc.bug
Subject: Obscure bug involving bit fields, asm and ({ })
Message-ID: <8907131331.AA02113@gipsi-future.gipsi.fr>
Date: 13 Jul 89 13:31:17 GMT
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: bruno@gipsi.gipsi.fr
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 74