home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: sparky!uunet!uunet.ca!wildcan!sq!msb
- From: msb@sq.sq.com (Mark Brader)
- Subject: Re: How is struct assignment defined (idle query)?
- Message-ID: <1992Sep4.083255.14897@sq.sq.com>
- Organization: SoftQuad Inc., Toronto, Canada
- References: <715547606snx@grendel.demon.co.uk>
- Date: Fri, 4 Sep 92 08:32:55 GMT
- Lines: 24
-
- > Does ANSI say that structure assignment is done by member-wise copy or
- > by bit-wise copying?
-
- I think the standard is actually ambiguous. There's no direct
- discussion of this unless I've forgotten something, so we have to
- see what it says about the meaning of structs.
-
- Well, section 3.1.2.5 (ANSI numbering; 6.1.2.5 in ISO) says that a
- struct is a "sequentially allocated nonempty set of member objects".
- This should mean that its value is the ordered set of the values of
- the members, and therefore that a member-wise copy is sufficient.
-
- On the other hand, section 3.5.2.1 (6.5.2.1) says that "there may...
- be unnamed padding within a structure object..."; *this* seems to
- mean that the padding, as well as the members, is part of the struct
- and has to be copied -- in other words, mandating bit-wise copying.
-
- I see no reason to prefer one reading or the other.
- --
- Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb@sq.com
- "I'm a little worried about the bug-eater," she said. "We're embedded
- in bugs, have you noticed?" -- Niven, "The Integral Trees"
-
- This article is in the public domain.
-