Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

Hirofumi Saito

unread,
Mar 14, 2008, 7:16:20 AM3/14/08
to bug-...@gnu.org, Duncan Moore
Duncan Moore wrote.
> I've compiled gawk 3.1.6 on an ARM 710 platform using gcc 4.1.1, and running
> the random number test case gawk-3.1.6/test/rand.awk:

In my Debian Sarge on Zaurus (ARM architecture), same error occurs.


> A fix for this (which will not affect other platforms) is:

This patch works good in my Zaurus.

I don't know this error depends on only ARM, but in my Fedora8 (i586)
this error does not occur.

Regards,

Hirofumi.


Andrew J. Schorr

unread,
Mar 14, 2008, 9:10:25 AM3/14/08
to Duncan Moore, bug-...@gnu.org
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


0 new messages