Skip to content

Codegen issue: Cast to fat pointer #33

@danielsn

Description

@danielsn
#![feature(layout_for_ptr)]                                                                        
use std::mem;                                                                                      
use std::sync::Arc;                                                                                
use std::sync::Mutex;                                                                              

pub trait Subscriber {                                                                             
    fn process(&mut self);                                                                         
    fn interest_list(&self);                                                                       
}                                                                                                  

struct DummySubscriber {                                                                           
}                                                                                                  

impl DummySubscriber {                                                                             
    fn new() -> Self {                                                                             
        DummySubscriber {}                                                                         
    }                                                                                              
}                                                                                                  

impl Subscriber for DummySubscriber {                                                              
    fn process(&mut self) {}                                                                       
    fn interest_list(&self) {}                                                                     
}                                                                                                  

fn main() {                                                                                        
    let v = unsafe { mem::size_of_val_raw(&5i32) };                                                
    assert!(v == 4);                                                                               

    let x : [u8;13] = [0; 13];                                                                     
    let y: &[u8] = &x;                                                                             
    let v = unsafe { mem::size_of_val_raw(y) };                                                    
    assert!(v == 13);                                                                              

    let s : Arc<Mutex<dyn Subscriber>> = Arc::new(Mutex::new(DummySubscriber::new()));             
}

Metadata

Metadata

Assignees

Labels

[C] BugThis is a bug. Something isn't working.[F] CrashKani crashed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions