Path: utzoo!attcan!uunet!tektronix!tekcrl!tekcrl.CRL.TEK.COM!barts From: barts@tekcrl.CRL.TEK.COM (Bart Schaefer) Newsgroups: comp.lang.c Subject: Overlapping assignments Message-ID: <3008@tekcrl.CRL.TEK.COM> Date: 1 Sep 88 16:35:14 GMT Sender: barts@tekcrl.CRL.TEK.COM Reply-To: barts@tekcrl.CRL.TEK.COM (Bart Schaefer) Followup-To: comp.lang.c Organization: Tektronix, Inc., Beaverton, OR. Lines: 36 Suppose I make the following declaration: union node { struct cell { char tag; double val; } n_cell[2]; struct vec { short count; struct cell args[3]; } n_vec; } some_node; (This is actually a minimized version of a much more complex union, so please don't tell me better ways I could have made that particular declaration in order to avoid the question I'm about to ask.) Given that declaration, is the following assignment guaranteed to work for any (integer) values of i and j (assuming a compiler that supports structure assignment)? some_node.n_cell[i] = some_node.n_vec.args[j]; I *know* that I can't make *two* such assignments in succession for the same union node and expect anything sensible to happen, but as it turns out I never need to do more than one at a time. My concern is that, for example, n_cell[0] may overlap n_vec.args[0] by as much as 7 bytes (given 2-byte shorts and 8-byte doubles). I realize that it would be safer to declare a temporary struct cell and use two assignments, but I would like to avoid that if possible, because the actual struct involved is rather large and my stack space is very limited. I need to compile this on at least 3 different machines, each with a different OS and C compiler, none of which are draft-ANSI conformant. Thanks in advance.