[Debburn-devel] [PATCH] fixes for aliasing bugs

Peter Samuelson peter at p12n.org
Thu Sep 28 20:21:22 UTC 2006


[Albert Cahalan]
> >It occurred to me after sending this that I didn't actually know what
> >(unsigned)*inp would do.  As it turns out, it sign-extends to int
> >_before_ interpreting as unsigned int, the opposite of what I had
> >expected.

> Assuming you just want to eliminate a warning about a signed value
> as an array index, I think you want this:
> 
> a2h[*inp - 192u];

No, that gives the wrong result if *inp is a signed char with a value
of, say, -15 (that is, 0xf1) - this will yield an array index of -207.
If that is interpreted as an unsigned value, like a size_t, it becomes
4294967089.  Neither is what we want: what we want is 49.  You have to
cast *inp to unsigned char first, that's just all there is to it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/debburn-devel/attachments/20060928/5bffc040/attachment.pgp


More information about the Debburn-devel mailing list