Bug 17326 - Wrong integer display because of use of %lu
Summary: Wrong integer display because of use of %lu
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R-devel (trunk)
Hardware: All All
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-08-19 07:52 UTC by Suharto Anggono
Modified: 2017-08-19 07:52 UTC (History)
0 users

See Also:


Attachments
C test functions (297 bytes, text/x-csrc)
2017-08-19 07:52 UTC, Suharto Anggono
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Suharto Anggono 2017-08-19 07:52:40 UTC
Created attachment 2289 [details]
C test functions

This is a follow-up of Bug 17292 Comment 7.


Function 'SET_STRING_ELT' in memory.c has this fragment.
    if (i < 0 || i >= XLENGTH(x))
	error(_("attempt to set index %lu/%lu in SET_STRING_ELT"),
	      i, XLENGTH(x));

Similarly, function 'SET_VECTOR_ELT' in memory.c has this fragment.
    if (i < 0 || i >= XLENGTH(x))
	error(_("attempt to set index %lu/%lu in SET_VECTOR_ELT"),
	      i, XLENGTH(x));

Because %lu is for an unsigned integer type, displayed 'i' in the error message is not quite right when 'i' is negative. An example is the error message in example in Description of Bug 17292.

Attached is a source code of C functions to be called from R by .Call that trigger error from the above code fragments.


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?