Skip to content

Bus error when referencing a static variant #11587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sehugg opened this issue Jan 16, 2014 · 1 comment
Closed

Bus error when referencing a static variant #11587

sehugg opened this issue Jan 16, 2014 · 1 comment

Comments

@sehugg
Copy link

sehugg commented Jan 16, 2014

The following code leads to a Bus Error when executed. Function is Struct::new::h402a74079d4792bdD2aR::v0.0

rustc 0.10-pre (149fc76 2014-01-15 13:51:50 -0800)
host: x86_64-apple-darwin

Also repeatable on 0.9.

static NotPresent: Option<~int> = None;

pub struct Struct
{
  option: Option<~int>
}

impl Struct
{
   pub fn new() -> Struct { Struct {
     option: NotPresent
   } }
}

fn main()
{
    let dc = Struct::new();
    assert!(dc.option.is_none());
}
@alexcrichton
Copy link
Member

Closing as a dupe of #10577, the move is attempting to zero-out the original location (a read-only static) causing a bus error.

flip1995 pushed a commit to flip1995/rust that referenced this issue Oct 6, 2023
new lint: `into_iter_without_iter`

Closes rust-lang#9736 (part 2)

This implements the other lint that my earlier PR missed: given an `IntoIterator for &Type` impl, check that there exists an inherent `fn iter(&self)` method.

changelog: new lint: `into_iter_without_iter`

r? `@Jarcho` since you reviewed rust-lang#11527 I figured it makes sense for you to review this as well?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants