🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6376

gcc 2.7.0 bug

#6376
From: Dave Ray
Date: Thu, 07 Dec 1995 00:00
124 lines
3764 bytes
Problem:
When compiling on a SPARCstation SLC with gcc 2.7.0, extra initialization is
added to a structure that uses Labeled Elements.  This extra initialization
appears to be added only when a Labeled structure is a member of the outer
structure.



file foo.c:
struct abc {
   int a;
   int b;
   int c;
};
struct def {
   int d;
   int e;
   struct abc f;
} xyz = {
   .d = 1,
#ifdef SHOW_BUG
   .f = {
      .a = 2,
      .b = 3,
      .c = 4
   }
#endif /* SHOW_BUG */
};
main ()
{
}



To see the bug:
rabbit> gcc -v -S -DSHOW_BUG foo.c
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/specs
gcc version 2.7.0
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(bsd) -Acpu(sparc) -Amachine(sparc) -DSHOW_BUG foo.c /usr/tmp/cca16996.i
GNU CPP version 2.7.0 (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/sparc-sun-sunos4.1.3/include
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/cc1 /usr/tmp/cca16996.i -quiet -dumpbase foo.c -version -o foo.s
GNU C version 2.7.0 (sparc) compiled by CC

=> foo.s has:
gcc2_compiled.:
___gnu_compiled_c:
	.global _xyz
.data
	.align 4
_xyz:
	.word	1
	.skip 4           <------- extra skip is generated
	.skip 4
	.word	2
	.word	3
	.word	4
.text
	.align 4
	.global _main
	.proc	04
_main:
	!#PROLOGUE# 0
	save %sp,-104,%sp
	!#PROLOGUE# 1
	call ___main,0
	nop
L1:
	ret
	restore



To see a case where the bug does not occur:
rabbit> gcc -v -S foo.c           
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/specs
gcc version 2.7.0
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=7 -Dsparc -Dsun -Dunix -D__GCC_NEW_VARARGS__ -D__sparc__ -D__sun__ -D__unix__ -D__GCC_NEW_VARARGS__ -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(bsd) -Acpu(sparc) -Amachine(sparc) foo.c /usr/tmp/cca16999.i
GNU CPP version 2.7.0 (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/sparc-sun-sunos4.1.3/include
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.7.0/cc1 /usr/tmp/cca16999.i -quiet -dumpbase foo.c -version -o foo.s
GNU C version 2.7.0 (sparc) compiled by CC.

=> foo.s has:
gcc2_compiled.:
___gnu_compiled_c:
	.global _xyz
.data
	.align 4
_xyz:
	.word	1
	.skip 16             <------ there is no extra skip here
.text
	.align 4
	.global _main
	.proc	04
_main:
	!#PROLOGUE# 0
	save %sp,-104,%sp
	!#PROLOGUE# 1
	call ___main,0
	nop
L1:
	ret
	restore


-------------------------------------------------------------------------------
Dave Ray  --  Harris Computer Systems Corporation (Night Hawk aviary)
   2101 W. Cypress Creek Road       http://www.hcsc.com
   M.S. #161                        phone: (954) 973-5090    fax: (954) 977-5580
   Ft. Lauderdale, FL  33309        Dave.Ray@mail.hcsc.com
Technical Details
Message-ID: <9512071617.AA14714@amber.ssd.csd.harris.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,fc11a2578687e209,start
X-Google-Attributes: gid113d02,public
From: daver@amber.ssd.hcsc.COM (Dave Ray)
Subject: gcc 2.7.0 bug
Date: 1995/12/07
Message-ID: <9512071617.AA14714@amber.ssd.csd.harris.com>
X-Deja-AN: 121175715
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: GNUs Not Usenet
newsgroups: gnu.gcc.bug