Conversation
|
That looks great. I could turn on the big bad rev.dep machine but I am not even sure it's needed. |
eddelbuettel
left a comment
There was a problem hiding this comment.
This looks good -- test on entry is the way to go. There might as always be other code paths but this is at a minimum a start if not even a solid 'squash' of that bug.
|
Are we sure I'm also fairly certain the actual issue here comes from this bit of cruel code. |
|
Perhaps we can return Or, alternatively -- instead of using I just hate the idea of this zero-length check becoming necessary. :| |
|
dataptr has the same problem, and I think we should add the same workaround, because all these accessors end up calling that macro I linked above, which doesn't check the length and therefore return an invalid pointer when the vector is empty. std::copy works fine with a null pointer, I tested it with the reprex provided by the update, but of course I can add a test. Note also that the vector cache sets start to zero upon initialization, but this is messed up when the update method is called. So this follows the initial idea of having a null pointer as the start of there is no start. |
Are you sure? Lines 77 to 81 in 7ff6ba2 |
|
The last one is |
|
Oh, I get what you mean, the other macro will return a valid address +1. Is that a valid memory address anyway? In the sense, it may be unallocated. |
Good question. I think the C++ standard guarantees that pointers to the "end" of an allocation are still valid, as long as you don't de-reference those pointers. I don't know if that extends to memory allocated from C, though... Honestly though, the right solution might just be for us to request R Core back out this change upstream. |
|
Ok, let's go back to |
|
Thanks @Enchufa2; sorry for being so nit-picky here! |
|
That's fine, that's the purpose of a review! |
Closes #1461. This happens because this returns
0x1for empty vectors. The question is whether we should do the same check in here. I think we should.Checklist
R CMD checkstill passes all tests