Another UB triggered in
|
CharacterVector listof_names(ListOf<NumericVector> x) { |
|
return x.names(); |
|
} |
The issue is in the definition
|
template <typename T> |
|
class ListOf |
|
: public NamesProxyPolicy<T> |
|
, public AttributeProxyPolicy<T> |
|
, public RObjectMethods<T> |
|
{ |
Since ListOf<T> is a wrapper, it should inherit from NamesProxyPolicy<ListOf<T>> instead, etc. Otherwise, this cast produces the UB:
|
NamesProxy names() { |
|
return NamesProxy( static_cast<CLASS&>(*this) ) ; |
|
} |
But then we need to avoid using methods that are not part of ListOf<T>, such as get__() and set__() (or define them). PR coming.
Another UB triggered in
Rcpp/inst/tinytest/cpp/ListOf.cpp
Lines 108 to 110 in e5b03df
The issue is in the definition
Rcpp/inst/include/Rcpp/vector/ListOf.h
Lines 25 to 30 in e5b03df
Since
ListOf<T>is a wrapper, it should inherit fromNamesProxyPolicy<ListOf<T>>instead, etc. Otherwise, this cast produces the UB:Rcpp/inst/include/Rcpp/proxy/NamesProxy.h
Lines 82 to 84 in e5b03df
But then we need to avoid using methods that are not part of
ListOf<T>, such asget__()andset__()(or define them). PR coming.