add a PROTECT in the cpp code as in RcppAttributes