dse2 remove wrong insn
Andrew Haley
aph@redhat.com
Mon Dec 12 14:21:00 GMT 2011
On 12/12/2011 01:48 PM, BELBACHIR Selim wrote:
> Everything seems good when I use a union instead of "*((int *)(&af))".
>
> But I think that "*((int *)(&af))" is a valid syntax to get the
> integer representation of my floating point value (in my test case
> 0x3F800000 for 1.0f in IEEE-754). It may be target dependant but I
> think it should work on target having 32 bits float and integer (and
> IEEE754 compliance).
It's legal syntax, but it's not semantically legal.
http://www.open-std.org/jtc1/sc22/wg...docs/n1124.pdf chapter 6.5
An object shall have its stored value accessed only by an lvalue
expression that has one of the following types:
— a type compatible with the effective type of the object,
— a qualified version of a type compatible with the effective type of
the object, — a type that is the signed or unsigned type corresponding
to the effective type of the object, — a type that is the signed or
unsigned type corresponding to a qualified version of the effective
type of the object,
— an aggregate or union type that includes one of the aforementioned
types among its members (including, recursively, a member of a
subaggregate or contained union), or
— a character type.
See also labs.qt.nokia.com/2011/06/10/type-punning-and-strict-aliasing/
Andrew.
More information about the Gcc
mailing list