[BusyBox 0004774]: Bitwise operations in awk applet are done the default signedness of longs, which varies with compilation options/platforms
bugs at busybox.net
bugs at busybox.net
Thu Aug 28 04:33:49 UTC 2008
The following issue has been SUBMITTED.
======================================================================
http://busybox.net/bugs/view.php?id=4774
======================================================================
Reported By: benoar
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 4774
Category: Standards Compliance
Reproducibility: always
Severity: minor
Priority: normal
Status: assigned
======================================================================
Date Submitted: 08-27-2008 21:33 PDT
Last Modified: 08-27-2008 21:33 PDT
======================================================================
Summary: Bitwise operations in awk applet are done the
default signedness of longs, which varies with compilation options/platforms
Description:
When using bitwise operations in awk applet, the signedness of the value
operated on depends on how busybox is compiled, because these operations
are defined to work on "long". This can lead to "strange" result when long
is signed by default, when using values higher than 2^31-1, i.e. :
echo|awk '{ print and(0x80000000,1) }'
gives 1 when compiled with signed long, whereas it gives 0 when compiled
with unsigned longs by default.
I don't know if there is a standard for bitwise operations in awk
(http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html doesn't
give me a clue), but most of the platform I have tested behave as if long
is unsigned by default.
Furthermore, working on signed values when doing bitwise operations is
awkward.
This may be a gcc bug, which uses the wrong default, I don't know. The
fact is that this bug affects openwrt on big endian platforms which use
signed long by default (I filled
https://dev.openwrt.org/cgi-bin/trac.fcgi/ticket/3946), contrary to
little-endian platform which use unsigned long.
I think the correct solution is to explicitly state that these bitwise
operations operate on unsigned long. A patch is attached to correct this
behavior. It only affects platforms that use signed long by default.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
08-27-08 21:33 benoar New Issue
08-27-08 21:33 benoar Status new => assigned
08-27-08 21:33 benoar Assigned To => BusyBox
08-27-08 21:33 benoar File Added: bitwise_ops_on_unsigned_long.patch
======================================================================
More information about the busybox-cvs
mailing list