Bug 964422
Summary: | R-bitops-1.0.5 is FTBS on ARM | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Peter Robinson <pbrobinson> |
Component: | R-bitops | Assignee: | josef radinger <cheese> |
Status: | CLOSED RAWHIDE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 19 | CC: | cheese, fweimer, tcallawa |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2013-08-16 14:30:52 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 245418 |
Description
Peter Robinson
2013-05-18 12:36:22 UTC
Any update? This is blocking a number of other R packages on ARM that all previously built fine 1.0.4.1 has the same bug, just not triggered by the less strict test. bitflip(-1) should be 0, but on arm, it is 4294967295. Something in this function is not correct on ARM: SEXP bitFlip(SEXP a, SEXP bitWidth ) { int i, n, *xbitWidth; unsigned int mask ; unsigned int tmp ; double *xa, *xaflip ; SEXP aflip ; PROTECT (a = AS_NUMERIC(a) ) ; PROTECT (bitWidth = AS_INTEGER(bitWidth) ) ; n=LENGTH(a) ; PROTECT (aflip = NEW_NUMERIC(n) ) ; xa=NUMERIC_POINTER(a) ; xaflip=NUMERIC_POINTER(aflip) ; xbitWidth=INTEGER_POINTER(bitWidth) ; mask = ( unsigned int ) -1 >> (32 - *xbitWidth) ; for (i=0; i<n; i++ ) { if ( !R_FINITE(xa[i]) || logb(xa[i])>31 ) xaflip[i]=NA_REAL ; else { tmp=(unsigned int) xa[i] ; xaflip[i]=(double) ( ~tmp & mask ) ; } } UNPROTECT(3) ; return (aflip) ; } This is the bug: tmp=(unsigned int) xa[i] ; Casting double to unsigned is undefined if the value is negative. Use this instead: tmp=xa[i] < 0 ? (int) xa[i] : (unsigned) xa[i]; Here's a small reproducer if you want to play with it: #include <stdio.h> int main(int argc, char **argv) { double v = 0.0; sscanf(argv[1], "%lf", &v); unsigned i = (int) v; printf("int = %08x\n", i); unsigned u = (unsigned) v; printf("unsigned = %08x\n", u); return 0; } [root@calxeda-arm-soc-02 ~]# ./a.out -1 int = ffffffff unsigned = 00000000 Thanks Florian! Fixed in R-bitops-1.0.5-3.fc20. Patch sent to upstream. |