Skip to content

llvm lint: buffer overflow in src/test/ui/foreign/foreign-truncated-arguments.rs #75839

Closed
@matthiaskrgr

Description

@matthiaskrgr

code from tests/ui/foreign/foreign-truncated-arguments.rs

// run-pass
// compile-flags: -O
// Regression test for https://github.com/rust-lang/rust/issues/33868

#[repr(C)]
pub struct S {
    a: u32,
    b: f32,
    c: u32
}

#[no_mangle]
#[inline(never)]
pub extern "C" fn test(s: S) -> u32 {
    s.c
}

fn main() {
    assert_eq!(test(S{a: 0, b: 0.0, c: 42}), 42);
}

When checked with rustc -Cpasses=lint src/test/ui/foreign/foreign-truncated-arguments.rs, this generates the following llvm-ir lint warning:

Undefined behavior: Buffer overflow
  %13 = load { i64, i32 }, { i64, i32 }* %12, align 4

repo @ 2342cc3

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationC-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-llvmWorking group: LLVM backend code generation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions