Commit aed58c1
Fix ambiguous Vector::operator[] on platforms without LONG_VECTOR_SUPPORT
On wasm32 (and other platforms where LONG_VECTOR_SUPPORT is not
defined) R_xlen_t is int while ptrdiff_t is long. Subscripting an
Rcpp::Vector with a long index then becomes ambiguous between the
member operator[] (which needs a long -> int conversion on the index)
and the built-in pointer subscript operator[](SEXPREC*, ptrdiff_t)
synthesised via the implicit Vector -> SEXP conversion (which needs a
user-defined conversion on the object but matches the index exactly).
The two implicit conversion sequences are mutually unrankable so
overload resolution fails.
Add a long-index overload that is only compiled when
LONG_VECTOR_SUPPORT is not defined, so LP64 builds (where R_xlen_t
== long already) are unaffected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8d2f8f8 commit aed58c1
2 files changed
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
1 | 8 | | |
2 | 9 | | |
3 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
340 | 348 | | |
341 | 349 | | |
342 | 350 | | |
| |||
0 commit comments