Closed
Description
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
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
matthiaskrgr commentedon Apr 27, 2019
Another example from rusts own codebase
src/test/run-pass/issues/issue-51907.rs ( when compiled with
rustc -C passes=lint -C opt-level=3
)jonas-schievink commentedon Apr 27, 2019
Nominating to figure out how bad this is. Might be related to #55976.
hanna-kruppe commentedon Apr 27, 2019
I believe LLVM's linting is in the wrong here. The purported type mismatch is that the caller passes
{}*
as first argument but the callee was declared with parameter type%Bar*
. But the pointee type doesn't matter [1], all pointers are passed the same, so this call is perfectly ABI-compatible.[1] slight caveat -- currently it still matters for
sret
"arguments", because those are not simply passing a pointer but modifying the stack layout based on the size of the pointed-to type, but I don't see that happening here.pnkfelix commentedon May 2, 2019
triage: P-high for two tasks: 1. resolve whether this is indeed an LLVM bug, and if so, 2. filing a bug against LLVM.
removing nomination since I don't think there's much to discuss beyond 1. what's already in @rkruppe's comment and 2. assigning the issue (like any other P-high T-compiler issue) to someone on the compiler team to address.
pnkfelix commentedon Jun 24, 2019
This seems like it was resolved between rustc 1.28.0 (9634041 2018-07-30) and rustc 1.29.0 (aa3ca19 2018-09-11)matthiaskrgr commentedon Jun 24, 2019
I can still reproduce with
rustc 1.37.0-nightly (929b48ec9 2019-06-21)
pnkfelix commentedon Jun 24, 2019
More specifically, it was resolved between rustc 1.29.0-nightly (e5f6498 2018-07-10) and rustc 1.29.0-nightly (64f7de9 2018-07-12)pnkfelix commentedon Jun 24, 2019
@matthiaskrgr hmm, interesting. Are you reproducing via the reduced version from this comment above (which is what I am doing)? Or some other reproduction?
7 remaining items