Skip to content

llvm lint: "Undefined behavior: Call argument type mismatches callee parameter type" with mixing debug and release #48310

Closed
@matthiaskrgr

Description

@matthiaskrgr

This was reduced from https://github.com/ogham/rust-ansi-term (lib crate) @ 090e0a383d73a43e2f80a7b466e8feeee97c4c76

add this to cargo.toml

[profile.release]
debug=true
opt-level=3

and this as your lib.rs:

use std::fmt;

pub struct Infix(bool, bool);

impl fmt::Display for Infix {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let f: &mut fmt::Write = f;
        write!(f, "")
    }
}

build with

$ RUSTFLAGS="-C passes=lint"  cargo build --release 
   Compiling ansi_term v0.10.2 (file:///tmp/rust-ansi-term)
Undefined behavior: Call argument type mismatches callee parameter type
  %6 = call zeroext i1 bitcast (i1 (%"core::fmt::Formatter"*, %"core::fmt::Arguments"*)* @"_ZN71_$LT$core..fmt..Formatter$LT$$u27$a$GT$$u20$as$u20$core..fmt..Write$GT$9write_fmt17hf4780c35b427924cE" to i1 ({}*, %"core::fmt::Arguments"*)*)({}* nonnull %4, %"core::fmt::Arguments"* noalias nocapture dereferenceable(48) %3), !dbg !119
    Finished release [optimized + debuginfo] target(s) in 0.20 secs

EDIT: meta:

rustc 1.25.0-nightly (58a8e0c27 2018-02-16)
binary: rustc
commit-hash: 58a8e0c27152e9306f8e0cd4fa3a162f5ae8e8c4
commit-date: 2018-02-16
host: x86_64-unknown-linux-gnu
release: 1.25.0-nightly
LLVM version: 6.0

// cc #7463

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions