Skip to content

noalias on a Box doesn't seem to have an impact when compiling without -C panic=abort #95323

Open
@jrmuizel

Description

@jrmuizel

I tried this code:

struct Foo {
    x: i32
}
#[inline(never)]
fn function2() { println!("foo"); }

#[inline(never)]
fn function1() -> Box<Foo> { Box::new(Foo { x: 4}) }

pub fn foo() {
    let foo: Box<_> = function1();
    let value1 = foo.x;
    function2();
    let value2 = foo.x;
    assert_eq!(value1, value2);
}

I expect the assert_eq! to be compiled away. However, this only happens with -C panic=abort.

I'm using rustc 1.61.0-nightly (c84f39e 2022-03-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-boxArea: Our favorite opsem complicationA-codegenArea: Code generationC-bugCategory: This is a bug.T-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