Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function merging paradox #119160

Closed
tmiasko opened this issue Dec 20, 2023 · 4 comments · Fixed by #119802
Closed

Function merging paradox #119160

tmiasko opened this issue Dec 20, 2023 · 4 comments · Fixed by #119802
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tmiasko
Copy link
Contributor

tmiasko commented Dec 20, 2023

use std::hint::black_box;

static F: fn() -> bool = f as fn() -> bool;
static G: fn() -> bool = g as fn() -> bool;

pub fn f() -> bool {
    F == G
}

pub fn g() -> bool {
    F != G
}

fn main() {
    assert_ne!(
        black_box(f as fn() -> bool)(),
        black_box(g as fn() -> bool)(),
        "(F == G) != (F != G)",
    );
}
$ rustc a.rs -O && ./a
thread 'main' panicked at a.rs:15:5:
assertion `left != right` failed: (F == G) != (F != G)
  left: true
 right: true

Meta

rustc --version --verbose:

rustc 1.76.0-nightly (f704f3b93 2023-12-19)
binary: rustc
commit-hash: f704f3b93b1543cf504ecca0052f9f8531b1f61f
commit-date: 2023-12-19
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.6
@tmiasko tmiasko added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. labels Dec 20, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 20, 2023
@nikic
Copy link
Contributor

nikic commented Dec 20, 2023

Minimized: https://llvm.godbolt.org/z/6a5E9nT9n

@nikic nikic self-assigned this Dec 20, 2023
@nikic nikic added I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 20, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 20, 2023
@bjorn3
Copy link
Member

bjorn3 commented Dec 20, 2023

Reminds me of #54685.

@nikic
Copy link
Contributor

nikic commented Dec 20, 2023

Upstream fix: llvm/llvm-project@8b8f2ef

@nikic nikic added the llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade label Dec 20, 2023
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 20, 2023
@tmiasko tmiasko added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 4, 2024
@bors bors closed this as completed in 062e7c6 Jan 11, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness llvm-fixed-upstream Issue expected to be fixed by the next major LLVM upgrade P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants