Skip to content

max of empty IntegerVector gives large negative number #883

@jackwasey

Description

@jackwasey

Not sure if this is designed to be somewhat consistent with R (which gives -Inf and a warning for max(integer(0)).

Rcpp::cppFunction('int getiv() { IntegerVector IV = IntegerVector::create(); return max(IV); }')
getiv()
# [1] -368909088

Don't know where the number came from, other than perhaps a random memory location on my machine. If it is picking random memory locations, I guess it could cause some kind of memory access violation? I don't see an obviously correct choice of output in this case.

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