diff options
| author | bors <bors@rust-lang.org> | 2022-05-16 02:33:34 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-05-16 02:33:34 +0000 |
| commit | 56d540e0571ac1b0633ce10644224c495aaf42a0 (patch) | |
| tree | fc6b28edf61020b4855fd6a34efe65cc42b60c47 /compiler/rustc_mir_dataflow/src/framework/graphviz.rs | |
| parent | cdd74fc7b19805c65c7d6f759ec6871be1c38fce (diff) | |
| parent | 09dc24bc04ed162b92790195f2f84bc674cc3025 (diff) | |
| download | rust-56d540e0571ac1b0633ce10644224c495aaf42a0.tar.gz rust-56d540e0571ac1b0633ce10644224c495aaf42a0.zip | |
Auto merge of #97053 - CAD97:realloc-clarification, r=dtolnay
Remove potentially misleading realloc parenthetical
This parenthetical is problematic, because it suggests that the following is sound:
```rust
let layout = Layout::new::<[u8; 32]>();
let p1 = alloc(layout);
let p2 = realloc(p1, layout, 32);
if p1 == p2 {
p1.write([0; 32]);
dealloc(p1, layout);
} else {
dealloc(p2, layout);
}
```
At the very least, this isn't the case for [ANSI `realloc`](https://en.cppreference.com/w/c/memory/realloc)
> The original pointer `ptr` is invalidated and any access to it is undefined behavior (even if reallocation was in-place).
and [Windows `HeapReAlloc`](https://docs.microsoft.com/en-us/windows/win32/api/heapapi/nf-heapapi-heaprealloc) is unclear at best (`HEAP_REALLOC_IN_PLACE_ONLY`'s description may imply that the old pointer may be used if `HEAP_REALLOC_IN_PLACE_ONLY` is provided).
The conservative position is to just remove the parenthetical.
cc `@rust-lang/wg-unsafe-code-guidelines` `@rust-lang/wg-allocators`
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/framework/graphviz.rs')
0 files changed, 0 insertions, 0 deletions
