Re: sha1 alignment bug
On Fri, 27 Apr 2001, Randolph Chung wrote:
> > suspect this has to do with gcc3 being weird.
>
> why would/should a compiler guarantee that a char foo[] array be word
> aligned by default?!
Well, the answer to that is complicated, and I think now with the hashes
class it is no longer true.. But since it was at the start of the class
and the class is always constructed via 'new', and a few other things that
used to be true but are not anymore make sure that it would be aligned.
> > I bet if you drop a unsigned long as the first element in the
> > structure your problem will go away.
>
> probably, but that sounds like a rather fragile hack. why not declare
> them as uint32_t arrays and cast them to char * as needed instead? or we
> can do the union fix we discussed.
Well, I'm just saying that will work too. The union thing is best, can't
use uint32_t's because they are made by a private macro sometimes.
Jason
Reply to: