Skip to content

eventual uses casts from immut to mut pointers #21

Closed
@apoelstra

Description

@apoelstra

In latest rust HEAD there is a lint for casting immutable pointers to mutable ones, which is undefined behaviour. This is hit by eventual:

src/core.rs:736:43: 736:57 error: mutating transmuted &mut T from &T may cause undefined behavior,consider instead using an UnsafeCell, #[deny(mutable_transmutes)] on by default
src/core.rs:736             let s: &mut CoreInner<T, E> = mem::transmute(self);
                                                          ^~~~~~~~~~~~~~
src/core.rs:743:43: 743:57 error: mutating transmuted &mut T from &T may cause undefined behavior,consider instead using an UnsafeCell, #[deny(mutable_transmutes)] on by default
src/core.rs:743             let s: &mut CoreInner<T, E> = mem::transmute(self);
                                                          ^~~~~~~~~~~~~~
src/core.rs:750:43: 750:57 error: mutating transmuted &mut T from &T may cause undefined behavior,consider instead using an UnsafeCell, #[deny(mutable_transmutes)] on by default
src/core.rs:750             let s: &mut CoreInner<T, E> = mem::transmute(self);
                                                          ^~~~~~~~~~~~~~
src/core.rs:757:43: 757:57 error: mutating transmuted &mut T from &T may cause undefined behavior,consider instead using an UnsafeCell, #[deny(mutable_transmutes)] on by default
src/core.rs:757             let s: &mut CoreInner<T, E> = mem::transmute(self);

It is possible to fix this by having the offending functions take &mut self (and then propagating this to every function that calls them) which allows the library to compile. I didn't really look at how this affects users of the library; my only use is in rust-bitcoin which does not even compile on its own right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions