Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uupsi!sunic!dkuug!diku!thorinn From: thorinn@diku.dk (Lars Henrik Mathiesen) Newsgroups: comp.lang.c Subject: Re: Save to assign union member to each other ? Keywords: union, assignment Message-ID: <1991Feb8.184517.14109@odin.diku.dk> Date: 8 Feb 91 18:45:17 GMT References: <315@ptcburp.ptcbu.oz.au> Sender: news@odin.diku.dk (Netnews System) Organization: Department of Computer Science, U of Copenhagen Lines: 23 michi@ptcburp.ptcbu.oz.au (Michael Henning) writes: >Given >union { > int i; > double d; >} u; >is it legal to assign one member of the union to another? Examples: Under Semantics of 3.3.16.1 (Simple assignment), the C Standard says: "If the value being stored in an object is accessed from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects shall have qualified or unqualified version of a compatible type; otherwise the behavior is undefined." The answer to your question is no. -- Lars Mathiesen, DIKU, U of Copenhagen, Denmark [uunet!]mcsun!diku!thorinn Institute of Datalogy -- we're scientists, not engineers. thorinn@diku.dk