Closed
Description
Spawned off of #71416
Specifically this comment: #71416 (comment)
quoted here:
Unlike the other unsound features, this is one where we don't even have a plan for how to soundly implement it. Not sure how much I like keeping that around.
Can't we do something dynamic where we allocate
size + (align - 1)
and align it ourselves?
Also, this has been discussed before, hasn't it?
Activity
pnkfelix commentedon Apr 29, 2020
@rustbot prioritize
RalfJung commentedon Apr 29, 2020
@pnkfelix (in #71694)
size
is also statically unknown here, so yes this needsalloca
, that is indeed the entire point. ;)spastorino commentedon Apr 30, 2020
Assigning
P-medium
as discussed as part of the Prioritization Working Group process and removingI-prioritize
.Assigning to myself as a followup of #68304.
ldr709 commentedon Dec 21, 2020
Here's a small optimization: pick some default alignment, maybe 16, then allocate
size + max(align - default_align, 0)
bytes. Ifalign >= default_align
thenalign % default_align == 0
because they are both powers of two, so the offset required to align toalign
bytes isi * default_align
fori < align / default_align
, which is at most(align / default_align - 1) * default_align = align - default_align
. Ifalign < default_align
then the allocation will already be properly aligned, no offset required.Auto merge of rust-lang#111374 - tmiasko:align-unsized-locals, r=cjgi…