Re: Unions Redux
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Thu, 15 Mar 2007 04:25:51 -0500
Jack Klein wrote:
.... snip ...
There is no difference in aliasing in a union than there is via
pointer casting.
Not so. The compiler is able to insert conversion code to
implement a cast. It is not able to do so for an aliased union.
Which is why it is implementation or undefined behavior to access a
union component as other than the form in which it was stored.
To illustrate, consider a perverse 16 bit machine in which pointers
are machine addresses stored hi order byte first, and integers are
stored low order byte first. How is the compiler to know when to
flip the bytes when accessed through a union?
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: Unions Redux
- From: Robert Gamble
- Re: Unions Redux
- From: Pierre Asselin
- Re: Unions Redux
- References:
- Unions Redux
- From: Old Wolf
- Re: Unions Redux
- From: Jack Klein
- Unions Redux
- Prev by Date: Re: Are static functions better optimized by compilers?
- Next by Date: Re: modifying the strings pointed to by argv
- Previous by thread: Re: Unions Redux
- Next by thread: Re: Unions Redux
- Index(es):
Relevant Pages
|