[gnu.gcc.bug] Alignment bug in 1.36.93

wood@DG-RTP.DG.COM (Tom Wood) (02/10/90)

With the 1.36.93 version of GCC and this input file, I get a bad
alignment error:

	as: error (jackson-align.s:14): Odd address

Here's the source:

extern char *reg_names[1];

char *hello= "hi";
char *reg_names[] = { "fp31", };

Here's the sun output:

#NO_APP
gcc_compiled.:
.globl _hello
.data
LC0:
	.ascii "hi\0"
	.even
_hello:
	.long LC0
.globl _reg_names
LC1:
	.ascii "fp31\0"
_reg_names:
	.long LC1
 
Notice that there is no invocation of ASM_OUTPUT_ALIGN before the label
_reg_names.  The relevant code in varasm.c (around line 549) is:

  /* Output the alignment of this data.  */
  for (i = 0; DECL_ALIGN (decl) >= BITS_PER_UNIT << (i + 1); i++);
  if (i > 0)
    ASM_OUTPUT_ALIGN (asm_out_file, i);

  /* Output the name(s) of this data.  */
  ASM_OUTPUT_LABEL (asm_out_file, name);

In this case, DECL_ALIGN (decl) is 1, but if you leave out the array
bounds in the extern declaration it is properly aligned and everything
goes OK.  I think something's going wrong in grokdeclarator\c-decl.c
around about the call to build_decl for the variable.

Film at 11.
-- 
Tom Wood