[Debburn-devel] [PATCH] fixes for aliasing bugs
Albert Cahalan
acahalan at gmail.com
Thu Sep 28 15:50:30 UTC 2006
On 9/28/06, Peter Samuelson <peter at p12n.org> wrote:
> > Peter Samuelson wrote:
> > > } else {
> > > + char *tmp = a2h[((unsigned)*inp) - 192];
> > > + size_t tmpl = strlen(tmp);
> > > + memcpy(outp, tmp, tmpl+1);
> > > + outp += tmpl;
> > > }
>
> 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.
>
> So, yeah, please ignore anything I ever say about integer type casting,
> as I clearly don't have a clue.
Assuming you just want to eliminate a warning about a signed value
as an array index, I think you want this:
a2h[*inp - 192u];
More information about the Debburn-devel
mailing list