Skip to content

Uninitialized bytes get copied to the buffer when creating an uninitialized tuple #83087

Closed
@MSxDOS

Description

@MSxDOS

In this example:

use std::mem::MaybeUninit;

extern {
    fn fill(p: *mut u16);
}

pub unsafe fn test() {
    let (mut buffer, mut buffer2): ([u16; 512], [u16; 256]) = MaybeUninit::uninit().assume_init();
    fill(buffer.as_mut_ptr());
    fill(buffer2.as_mut_ptr())
}

there is a call to memcpy for one of the buffers that copies uninitialized data to it.
https://rust.godbolt.org/z/z1zcor

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-slowIssue: Problems and improvements with respect to performance of generated code.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions