home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2571 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.4 KB  |  35 lines

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