Re: strict aliasing violation

2010-01-25 Thread Jonathan Wakely
On 25 January 2010 15:51, Piotr Wyderski: > Andrew Haley wrote: >   union { float f; uint32 i; } u = {.f = v};   return u.i; >>> >>> Nope, that is not allowed either. >> >> Of course it is allowed.  It's a legitimate gcc extension, and it's >> supported by many other compilers too. > > It

Re: strict aliasing violation

2010-01-25 Thread Piotr Wyderski
Andrew Haley wrote: >>>   union { float f; uint32 i; } u = {.f = v}; >>>   return u.i; >> >> Nope, that is not allowed either. > > Of course it is allowed.  It's a legitimate gcc extension, and it's > supported by many other compilers too. It's a C extension, according to the documentation. In C+

Re: strict aliasing violation

2010-01-25 Thread Richard Guenther
On Mon, Jan 25, 2010 at 3:42 PM, Erik Trulsson wrote: > On Mon, Jan 25, 2010 at 02:19:04PM +0100, Richard Guenther wrote: >> On Mon, Jan 25, 2010 at 1:24 PM, Piotr Wyderski >> wrote: >> > I have a hash function hash(T v) overloaded for >> > all integral types. I want to provide a variant for >> >

Re: strict aliasing violation

2010-01-25 Thread Andrew Haley
On 01/25/2010 02:42 PM, Erik Trulsson wrote: > On Mon, Jan 25, 2010 at 02:19:04PM +0100, Richard Guenther wrote: >> On Mon, Jan 25, 2010 at 1:24 PM, Piotr Wyderski >> wrote: >>> I have a hash function hash(T v) overloaded for all integral >>> types. I want to provide a variant for float and doubl

Re: strict aliasing violation

2010-01-25 Thread Erik Trulsson
On Mon, Jan 25, 2010 at 02:19:04PM +0100, Richard Guenther wrote: > On Mon, Jan 25, 2010 at 1:24 PM, Piotr Wyderski > wrote: > > I have a hash function hash(T v) overloaded for > > all integral types. I want to provide a variant for > > float and double, which should work as follows: > > take the

Re: strict aliasing violation

2010-01-25 Thread Richard Guenther
On Mon, Jan 25, 2010 at 1:24 PM, Piotr Wyderski wrote: > I have a hash function hash(T v) overloaded for > all integral types. I want to provide a variant for > float and double, which should work as follows: > take the floating-point value, treat its binary > representation as uint32_t/uint64_t a

Re: strict aliasing violation

2010-01-25 Thread Andreas Schwab
Piotr Wyderski writes: > However, GCC warns me about strict aliasing > rules violation, which is technically correct, but > in this case is intended. How do I perform this > conversion ina GCC-friendly way? Even that > produces a warning: > > inline hash_type hash(float v) { > > retur