bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk 3.1.6: rand.awk test case alignment problem


From: Andrew J. Schorr
Subject: Re: gawk 3.1.6: rand.awk test case alignment problem
Date: Fri, 14 Mar 2008 09:10:25 -0400
User-agent: Mutt/1.4.2.2i

Hi,

On Thu, Mar 13, 2008 at 02:53:56PM -0000, Duncan Moore wrote:
> The reason for the error, is that char array 'state' in builtin.c is not
> word aligned, and it is cast to an int*. This causes problems on
> architectures that require ints to be word aligned. There is a comment in
> random.c that this causes bus errors on the Sparc platform, but the code
> does not appear to have been fixed. Other platforms could be affected too.

Isn't this really a bug in the initstate function?  If the argument
needs to be an integer-aligned array, then shouldn't the prototype
make that clear?  But then again, the prototype is specified in the
standard:

   http://www.opengroup.org/onlinepubs/009695399/functions/initstate.html

So if the standard API requires 'char *', then maybe the initstate
implementation needs to be fixed?  Or is that impossible?   This
seems to be a mess.  One possibility might be to ignore the leading
unaligned bytes of the state array, but this might give unexpected
results.

I think even on x86, there is a performance penalty for unaligned
access.

Regards,
Andy




reply via email to

[Prev in Thread] Current Thread [Next in Thread]