Skip to content

volatile_load + newtype = LLVM assertion #23550

Closed
@japaric

Description

@japaric

STR

#![crate_type = "lib"]

mod mmio {
    use std::intrinsics;

    pub struct RO<T>(T) where T: Copy;

    impl<T> RO<T> where T: Copy {
        pub fn get(&self) -> T {
            unsafe {
                intrinsics::volatile_load(&self.0)
            }
        }
    }
}

struct Gpio {
    idr: mmio::RO<Idr>,
}

#[derive(Copy)]
struct Idr(u32);

fn ice(gpio: &Gpio) -> Idr {
    gpio.idr.get()
}

Output

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:1083: void llvm::StoreInst::AssertOK(): Assertion `getOperand(0)->getType() == cast<PointerType>(getOperand(1)->getType())->getElementType() && "Ptr must be a pointer to Val type!"' failed.

I think this should work given that Idr is a newtype over a copyable/primitive type.

Metadata

Metadata

Assignees

Labels

A-codegenArea: Code generationI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions