[Debburn-devel] [PATCH] fixes for aliasing bugs
Albert Cahalan
acahalan at gmail.com
Fri Sep 29 05:23:02 UTC 2006
On 9/28/06, Peter Samuelson <peter at p12n.org> wrote:
> [Albert Cahalan]
> > 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.
Rethinking things a bit...
a2h[*inp & 0x3f]
More information about the Debburn-devel
mailing list