Skip to content

Bug in assigning SEXP to List #128

Description

@kevinushey

Related to this SO post:

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
List test_list(SEXP x){
    List L;
    L = x;
    return L;
}

/*** R
test_list( list(1, 2, 3) )
*/

just gives

> test_list( list(1, 2, 3) )
list()

This is because of the odd comma-initialization operator=, in Vector.h:

internal::ListInitialization<iterator,init_type> operator=( init_type x){
    iterator start = begin() ; *start = x; 
    return internal::ListInitialization<iterator,init_type>( start + 1 ) ; ;
}

This hijacks the normal operator= and breaks things here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions