RE: [Linux-ia64] C union on ia-64

From: Boehm, Hans <hans_boehm_at_hp.com>
Date: 2001-10-25 05:46:41
That slide looks to me like it escaped from a presentation on 64-bit Windows
programming, where "unsigned long" is 4 bytes long, unlike "void *", and
where it's customary to call both types by different names.  

It is never legal C to union the two structures store into one structure
field, and retrieve the value through a field in the other structure.  In
many cases it may work, but it is officially undefined, and hence allowed to
confuse the compiler's alias analysis.  Thus the compiler is entitled to
generate incorrect code.  This applies to all platforms.

In the 64-bit Windows case, this sort of thing is guaranteed to fail, since
the fields also don't line up correctly.  On the Linux side, there is no
difference between the 64-bit and 32-bit cases.  

Unless there's a better explanation, could someone at Intel correct this?

Hans

> -----Original Message-----
> From: Gururaj Ananthateerta [mailto:gururaj@cup.hp.com]
> Sent: Wednesday, October 24, 2001 11:53 AM
> To: Andreas Schwab
> Cc: KOCHI, Takayoshi; linux-64
> Subject: Re: [Linux-ia64] C union on ia-64
> 
> 
> http://developer.intel.com/design/itanium/linuxDDPorting/sld025.htm
> 
> The above link provides an example.
> 
> 
> 
> Andreas Schwab wrote:
> 
> > Gururaj Ananthateerta <gururaj@cup.hp.com> writes:
> >
> > |> Anyone experienced (memory corruption ) problems with 
> unions on ia-64.
> > |> I have found couple of documents which discourages the 
> use of unions on
> > |> ia-64 in particular.
> >
> > Please expand.  Unions are an integral part of C, without 
> them you could
> > not call it C.
> >
> > Andreas.
> >
> > --
> > Andreas Schwab                                  "And now 
> for something
> > Andreas.Schwab@suse.de                          completely 
> different."
> > SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
> > Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> 
> 
> _______________________________________________
> Linux-IA64 mailing list
> Linux-IA64@linuxia64.org
> http://lists.linuxia64.org/lists/listinfo/linux-ia64
> 
Received on Wed Oct 24 12:46:46 2001

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:05 EST