Code change:
This is a variant of that was not fixed by still fails with
Given that libcore and liballoc enable this feature, I am rather concerned they could inadvertently use it in a way that is still unsound. Also, unless we can fix this, the feature should probably be to to warn people against using it.
rustc bootstraps successfully with applied, so at least right now that does not seem to be the case (modulo the part of libstd that rustc never monomorphizes). Of course, that could change any time, there is no check for this.
Yes, thanks for opening this. To be specific, the issue here is centered on this line: and the fact that we have , and LLVM alloca's don't respect the alignment requirements, right? I think there may be a separate issue on that. (Link?) But: one thing we had discussed was separating out the "sound" part and the "unsound" part into distinct feature gates, so that we can enable only the former in libstd. Perhaps that's a good focus for this issue?
cc who had discussed the separate feature gate, and who might be interested in doing the follow-up work to create that gate.
Yes. Oh, I didn't know that. Let's see if someone finds it.^^ 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.
Yes, I see that argument. I'm reminded of , which limits the max alignment to 4K because of limits in dynamic linkers, though there's no real connection. It's just that part of the challenge here is that the alignment of a is totally unknown -- it's not like we can conservatively align to 64 bytes or something.
If lands we could conservatively align to 4k here. :rofl: (no I am not serious)
Assigning as , removing and nominating for discussion on our next weekly meeting.
Can't we do something dynamic where we allocate and align it ourselves? Also, this has been discussed before, hasn't it?
With being stable, this can be observed in stable compiler: EDIT: its fixed in nightly, never mind.
I don't know -- in we mostly talked about how to mitigate the effect on stable Rust. D'oh, I somehow forgot that one can manually implement "aligned" allocation on top of an unaligned allocator. Of course that would work. That's probably better than killing this part of codegen entirely.^^
, leaving the nomination up for now as requested by He wants to open some fresh issues about this.
Now that I've created more specific issues to track the important sub-tasks identified here, I think we can remove this from the nominated tickets.
Given that this feature has been removed from core/alloc and is unstable, I'm going to downgrade this to P-medium. This should obviously block stabilization of , but doesn't need special attention outside of that.

Related discussion:
text: bug!("store_unsized called with a sized value") }; <del> // FIXME: choose an appropriate alignment, or use dynamic align somehow let max_align = Align::from_bits(128).unwrap(); let min_align = Align::from_bits(8).unwrap(); // Allocate an appropriate region on the stack, and copy the value into it let (llsize, _) = glue::size_and_align_of_dst(bx, unsized_ty, Some(llextra)); let lldst = bx.byte_array_alloca(llsize, max_align); bx.memcpy(lldst, max_align, llptr, min_align, llsize, flags); </del> <ins> // Allocate an appropriate region on the stack, and copy the value into it. Since alloca // doesn't support dynamic alignment, we allocate an extra align - 1 bytes, and align the // pointer manually. let (size, align) = glue::size_and_align_of_dst(bx, unsized_ty, Some(llextra)); let one = bx.const_usize(1); let align_minus_1 = bx.sub(align, one); let size_extra = bx.add(size, align_minus_1); let min_align = Align::ONE; let alloca = bx.byte_array_alloca(size_extra, min_align); let address = bx.ptrtoint(alloca, bx.type_isize()); let neg_address = bx.neg(address); let offset = bx.and(neg_address, align_minus_1); let dst = bx.inbounds_gep(bx.type_i8(), alloca, &[offset]); bx.memcpy(dst, min_align, llptr, min_align, size, MemFlags::empty()); </ins> // Store the allocated region and the extra to the indirect place. <del> let indirect_operand = OperandValue::Pair(lldst, llextra); </del> <ins> let indirect_operand = OperandValue::Pair(dst, llextra); </ins> indirect_operand.store(bx, indirect_dest); } }