Skip to content

[MaybeUninit::uninit(); N] memsets memory #96274

Closed
@SUPERCILEX

Description

@SUPERCILEX

I tried this code (from #93668 (comment)):

let mut p = [MaybeUninit::<u8>::uninit(); 571];
// VS
let mut p = MaybeUninit::<[u8; 571]>::uninit();

Godbolts: https://godbolt.org/z/341fEjqMd, https://godbolt.org/z/K9dMx8Whr

I expected to see this happen: no memset.

Instead, this happened: uninitialized memory is not actually uninitialized.

The docs explicitly say that these two should be equivalent: https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#method.uninit_array

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions