Piotr Wyderski <piotr.wyder...@gmail.com> 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) {
>
>         return hash(*reinterpret_cast<const
> std::uint32_t*>(reinterpret_cast<const char*>(&v)));
>     }
>
> but I expected char* to be allowed to alias anything.

Only when used as the type to access the object, but you access it as
uint32_t.  The intermediate cast is irrelevant for aliasing
consideration.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Reply via email to