Fix assertion on empty array case - #13942
Conversation
gasche
left a comment
There was a problem hiding this comment.
Two comments:
-
Another approach would have been to move the assertion after the bound check. I like your current approach a bit more because it is explicit about the intended dynamic type of the input.
-
I have mixed feelings about silencing an assert failure (in debug mode) when calling
unsafe_{get,set}on empty arrays, which is undefined behavior. On the other hand, by this reasoning we could also assert that the access is in-bounds in general, and we don't do this, so allowing accesses on 0-sized atoms is arguably consistent.
|
I'm not sure whether or not we wanted a Changes entry, but I was tempted to click "merge" so I added the label to skip it. Please feel free to just direct-push one if you forgot but think that one is useful. |
|
I just force-pushed an amended commit with the changelog updated. |
Fixes #13939.
For consistency, I added an assertion in
caml_floatarray_unsafe_setwhere it was absent before.