Skip to content

Conversation

@hkBst
Copy link
Contributor

@hkBst hkBst commented Oct 22, 2024

self.cursor.sub(skip) must point inside the allocation of this object or this is UB, not to mention the possibility that if skip is very large self.cursor.sub(skip) may underflow and fail to trigger the debug_assertion.

@hkBst
Copy link
Contributor Author

hkBst commented Oct 22, 2024

Apparently offset_from stabilized in 1.47.0 (35 versions behind 1.82.0 times 6 weeks is 210 weeks or about 4 years old) is too new as MSRV=1.36. It "is equivalent to (self as isize - origin as isize) / (mem::size_of::() as isize), except that it has a lot more opportunities for UB, in exchange for the compiler better understanding what you are doing.", but I suppose I can make that work if you really still care about 1.36...

`self.cursor.sub(skip)` must point inside the allocation of this object or this is UB, not to mention the possibility that if `skip` if very large self.cursor.sub(skip) may underflow and fail to trigger the debug_assertion.
@hkBst
Copy link
Contributor Author

hkBst commented Dec 6, 2024

MSRV is now 1.47.0, and this patch now passes all checks. There should not be any performance impact, since this only changes a debug_assert.

@seanmonstar seanmonstar merged commit 380f130 into seanmonstar:master Dec 6, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants