Skip to content

avitex/owning-ref-noalias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

owning_ref - noalias conflict

This repo is a minimal reproduction of the UB when compiling owning_ref v0.4.0.

Failing behaviour

Original failing case can be found here.

Source (extracted from src/main.rs)

fn helper(owning_ref: OwningRef<Box<Cell<u8>>, Cell<u8>>) -> u8 {
    owning_ref.as_owner().set(10);
    owning_ref.set(20);
    owning_ref.as_owner().get() // note this should return the value 20
}

LLVM IR (extracted from out/ub.ll)

; main::helper
; Function Attrs: noinline nounwind nonlazybind uwtable
define internal fastcc i8 @_ZN4main6helper17hceb6202a66c63cf6E(i8* noalias align 1 dereferenceable(1), i8*) unnamed_addr #2 personality i32 (i32, i32, i64, %"unwind::libunwind::_Unwind_Exception"*, %"unwind::libunwind::_Unwind_Context"*)* @rust_eh_personality {
bb8:
  store i8 20, i8* %1, align 1
  tail call void @__rust_dealloc(i8* nonnull %0, i64 1, i64 1) #8
  ret i8 10 ; note the compiler is returning the value 10, not 20
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published