This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C aliasing rules question.
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: 18 May 2003 23:46:55 +0200
- Subject: Re: C aliasing rules question.
- References: <Pine.LNX.4.44.0305182333470.457-100000@goofy>
Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
> static inline int f_trunc(float f)
> {
> f -= 0.5f;
> f += (3<<22);
> return *((int*)(char*)&f) - 0x4b400000;
> }
>
> Or is this still invalid?
Yes, you're still accessing an object of type "float" with an lvalue
of type "int".
> Is it at least ok to tell _gcc_ about the aliasing?
I don't think so. Even if it happens to work right now, I don't think
it should be supported in the long run. What's so bad about using a
union?
--
Falk