Bug 17327 - Wrong integer display because of use of %ld
Summary: Wrong integer display because of use of %ld
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Windows GUI / Window specific (show other bugs)
Version: R-devel (trunk)
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-08-19 09:57 UTC by Suharto Anggono
Modified: 2017-08-19 10:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Suharto Anggono 2017-08-19 09:57:33 UTC
This is a follow-up of Bug 17292 Comment 7.


Using %ld for R_xlen_t doesn't give the desired result when the number is 2^31 or more for 64-bit R on Windows. On Windows, long is 32-bit.

Instances:

* function 'do_psort' in sort.c
Example usage in R:
res <- sort(integer(2^31), partial = 2^31+1)

* function 'inspect_tree' in inspect.c
Example usage in R:
.Internal(inspect(raw(2^31)))


For 32-bit R, in Rinternals.h, R_xlen_t is int and %d can be used.
For 64-bit R, in Rinternals.h, R_xlen_t is ptrdiff_t and %td can be used. Is it available everywhere?