Skip to content

Function merging paradox #119160

Closed
Closed
@tmiasko

Description

@tmiasko
Contributor
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

Activity

added
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bugCategory: This is a bug.
on Dec 20, 2023
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Dec 20, 2023
nikic

nikic commented on Dec 20, 2023

@nikic
Contributor
self-assigned this
on Dec 20, 2023
added
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Dec 20, 2023
added
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Dec 20, 2023
bjorn3

bjorn3 commented on Dec 20, 2023

@bjorn3
Member

Reminds me of #54685.

nikic

nikic commented on Dec 20, 2023

@nikic
Contributor
added
llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
on Dec 20, 2023
apiraino

apiraino commented on Dec 20, 2023

@apiraino
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

added
P-highHigh priority
and removed
I-prioritizeIssue: Indicates that prioritization has been requested for this issue.
on Dec 20, 2023
added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Jan 4, 2024

5 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @nikic@apiraino@bjorn3@rustbot@tmiasko

    Issue actions

      Function merging paradox · Issue #119160 · rust-lang/rust