Skip to content

LLVM lint: Memory reference address is misaligned #28912

Closed
@sanxiyn

Description

@sanxiyn

This is a subissue of #7463.

pub enum H<A, B> {
    L(A),
    R(B),
}
pub fn test() -> H<i32, i64> {
    H::L(0)
}

Compile with rustc -C passes=lint and you get:

Undefined behavior: Memory reference address is misaligned
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* getelementptr inbounds ({ i8, i32, [8 x i8] }, { i8, i32, [8 x i8] }* @const3020, i32 0, i32 0), i64 16, i32 8, i1 false)

Manually setting alignment of const3020 to 8 in LLVM IR fixes the lint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions