[gnu.gcc.bug] Obscure bug involving bit fields, asm and

bruno@future.gipsi.fr (Bruno Verlyck) (07/13/89)

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