Uh oh!
There was an error while loading. Please reload this page.
Improve boxed docs - #34740
Conversation
There was a problem hiding this comment.
It would be better if this example didn't demonstrate code that is likely to cause a segfault. The typical use case for this is when you start off with a Box, convert it to a raw pointer with into_raw, and then need to restore it.
There was a problem hiding this comment.
I see. Just by curiosity: why would it likely cause a segfault in here?
There was a problem hiding this comment.
The Box ends up being a pointer to the stack, and is then freed when the
Box is dropped.
On Saturday, July 9, 2016, Guillaume Gomez notifications@github.com wrote:
In src/liballoc/boxed.rs
#34740 (comment):@@ -249,6 +249,14 @@ impl<T: ?Sized> Box {
/// This function is unsafe because improper use may lead to
/// memory problems. For example, a double-free may occur if the
/// function is called twice on the same raw pointer.
- ///
- /// # Examples
- ///
- /// ```
- /// let mut x = 5;
- /// let ptr = &mut x as *mut i32;
- /// let b = unsafe { Box::from_raw(ptr) };
I see. Just by curiosity: why would it likely cause a segfault in here?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/rust/pull/34740/files/297695d76da3a624e380ad9a190b8d3354605ef5#r70173240,
or mute the thread
https://github.com/notifications/unsubscribe/AIPosBuNJtBUz6ID429xaGrWDWV8j17rks5qUCdggaJpZM4JIqu_
.
GuillaumeGomez
commented
Jul 10, 2016
Updated. |
GuillaumeGomez
commented
Jul 10, 2016
@frewsxcv: Thanks! |
steveklabnik
commented
Jul 11, 2016
@bors: r+ rollup |
bors
commented
Jul 11, 2016
📌 Commit 1ef7bdc has been approved by |
…abnik Improve boxed docs Fixesrust-lang#29343. r? @steveklabnik
Fixes#29343.
r? @steveklabnik