🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5463

Compatibility of textually identical structs/unions

#5463
From: J. Stephen Adamczyk
Date: Mon, 05 Dec 1988 16:27
26 lines
1411 bytes
Is the following legal, according to the May 13 (88-001) draft?

struct {int a;} v1;
struct {int a;} v2 = {1};

void f() {
  v1 = v2;     /* <--- Are the structs compatible? */
}

For the assignment to be legal, the two struct types have to be
compatible.  To be compatible, they have to be "the same" (3.1.2.6).
According to 3.5.2.1 (semantics), "The presence of a struct-declaration-list
in a struct-or-union-specifier declares a new type, within a translation
unit."  Since I can't find any other section that says that the two
structs above are the same, I conclude that the two struct types are
incompatible, and therefore the assignment is not allowed.

I know that 3.1.2.6 says that "two structure, union, or enumeration
types declared in separate translation units are compatible if they have
the same number of members, the same member names, and compatible member
types".  However, this says nothing about types within one translation
unit.

Any thoughts?

Steve Adamczyk
Technical Details
Message-ID: <288@edg1.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!unmvax!ncar!ames!pasteur!ucbvax!ucsd!sdcsvax!ucsdhub!esosun!seismo!uunet!edg1!jsa

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!unmvax!ncar!ames!pasteur!ucbvax!ucsd!sdcsvax!ucsdhub!esosun!seismo!uunet!edg1!jsa
From: jsa@edg1.UUCP (J. Stephen Adamczyk)
Newsgroups: comp.std.c
Subject: Compatibility of textually identical structs/unions
Message-ID: <288@edg1.UUCP>
Date: 5 Dec 88 16:27:10 GMT
Organization: Edison Design Group, Inc., Edison, NJ
Lines: 26