Document revert conditions for `std::mem` functions, specifically `copy`
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
I'm trying to implement `remove` of `Vec` (ref #2014), but found that memory overflow occurs when I use `copy`
to reproduce:
``` rust
script;
use std::alloc::alloc;
use std::mem::copy;
fn main() {
let ptr = alloc(32);
copy(ptr, ptr + 8, 24); // memory overflow error
}
```
Interestingly, sway is happy with the following example
``` rust
script;
use std::alloc::alloc;
use std::mem::copy;
fn main() {
let ptr = alloc(32);
let new_ptr = alloc(24);
copy(new_ptr, ptr + 8, 24);
}
```
So I guess the memory overflow error occurs when the memory of `src` and the memory of `dst` overlap.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the std::mem::copy entry and the two examples in the issue. Document the conditions under which overlapping src and dst memory causes a memory overflow or revert, including the contrasting non-overlapping example. Done means the documented behavior matches both reproductions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100