|RS/6000 Optimizer breaks code -- suggestions? firstname.lastname@example.org (1990-08-18)|
|RS/6000 Optimizer breaks code -- suggestions? email@example.com (1990-08-21)|
|Re: RS/6000 Optimizer breaks code -- suggestions? firstname.lastname@example.org (1990-08-24)|
|Re: RS/6000 Optimizer breaks code -- suggestions? email@example.com (1990-08-25)|
|Re: RS/6000 Optimizer breaks code -- suggestions? firstname.lastname@example.org (1990-08-27)|
|Re: RS/6000 Optimizer breaks code -- suggestions? email@example.com (1990-08-27)|
|Re: RS/6000 Optimizer breaks code -- suggestions? firstname.lastname@example.org (1990-08-29)|
|From:||email@example.com (Dale Worley)|
|Keywords:||C, debug, optimize|
|Date:||Fri, 24 Aug 90 14:36:06 EDT|
[In reagard to two similar unions, only one of which has a tag, and which
don't do what the author expected.]
Note that you define a tag "g" here. Note that any other union or struct
that "happens" to look like it does not have to *really* be implemented
identically, *UNLESS* you reuse the tag! (I assume you have defined
"half" somewhere else). If you have severely different expectations, you
should take them up with the ANSI C Committee, as I believe this is in
keeping with the standard.
Here you define another union, but you did *NOT* use the tag "g". As a
result, the compiler has the freedom to "optimize" the layout of these
Strictly speaking, you're correct. However, for any sane implementation,
there are some tight constraints: a pointer to a union must point to each
of its members (ANSI 188.8.131.52) -- therefore, all members start at the same
place, and so unions of the same types of fields pretty will have to be
laid out the same.
Again, if two structs are members of a union, and they have an initial set
of members of the same type, then those members have to be laid out the
same way (ANSI 184.108.40.206).
How this applies in this particular example, I don't know precisely, but
it's likely that the optimizer is disregarding one or the other of these
Dale Worley Compass, Inc. firstname.lastname@example.org
Return to the
Search the comp.compilers archives again.