-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Closed
Copy link
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
The docs for Layout::from_size_align_unchecked state that:
size, when rounded up to the nearest multiple ofalign, must not overflowisize(i.e., the rounded value must be less than or equal toisize::MAX)
alloc::realloc's docs state a different constraint:
new_size, when rounded up to the nearest multiple oflayout.align(), must not overflow (i.e., the rounded value must be less thanusize::MAX).
So this would be legal according to alloc::realloc's docs:
let layout = alloc::Layout::from_size_align(1, 1);
let ptr1 = alloc::alloc(layout);
let ptr2 = alloc::realloc(ptr1, layout, usize::MAX);But this results in a call internally:
Layout::from_size_align_unchecked(usize::MAX, 1)...which is meant to be UB.
I assume this is just that the docs are out of date after #95295.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.