🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2477

BUG in GCC/G++ 1.34 - unnamed fields

#2477
From: Ron Guilmette
Date: Wed, 29 Mar 1989 00:56
53 lines
1871 bytes
It is often nice that GCC/G++ have a superset of ANSI-C
features.  In this case, it is not so nice.

I recently reported in these newsgroups that GCC/G++ seem
to support the notion of "unnamed" fields, even when these
fields are *not* bitfields (as required by ANSI C).  Well
perhaps I spoke too soon.

The following program exits with a non-zero exit code because
unnamed fields can be declared but are apparently ignored by
the compiler(s) when allocating space in a structure.

I hope that this will be fixed *not* be deleting the (extension)
feature (which I find very useful) but rather by making it work
for both bitfields and non-bitfields.

----------------------------------------------------------------------
extern void printf (const char*, ...);
extern void exit (int);

int test ();
int errors = 0;

void main ()
{
	exit ( (test () || errors) ? 1 : 0);
}

struct struct_1 {
	int	;
	int	;
	int	;
	int	field1;
};

struct struct_1 structure_var;
int offset;

int test ()
{
	offset = (int) &structure_var.field1 - (int) &structure_var;
	if (offset == 12 && sizeof (struct struct_1) == 16)
		return 0;
	else
		return -1;
}
-----------------------------------------------------------------------

// Ron Guilmette  -  MCC  -  Experimental (parallel) Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg
Technical Details
Message-ID: <8903290056.AA25522@riunite.aca.mcc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!MCC.COM!rfg
From: rfg@MCC.COM (Ron Guilmette)
Newsgroups: gnu.gcc.bug
Subject: BUG in GCC/G++ 1.34 - unnamed fields
Message-ID: <8903290056.AA25522@riunite.aca.mcc.com>
Date: 29 Mar 89 00:56:08 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 53