Skip to content

Instantly share code, notes, and snippets.

@pnkfelix
Created April 29, 2013 14:01
Show Gist options
  • Save pnkfelix/5481736 to your computer and use it in GitHub Desktop.
Save pnkfelix/5481736 to your computer and use it in GitHub Desktop.
example showing when rustc encourages uninitalized variable.
// CODE:
static s : int = 3;
static t : *int = &s as *int;
fn main() {
let mut x = 3;
unsafe {
x = *t;
}
io::println(fmt!("Hello World %d", x));
}
/* RUSTC:
% rustc /tmp/bug8.rs
/tmp/bug8.rs:5:12: 5:15 warning: value assigned to `x` is never read
/tmp/bug8.rs:5 let mut x = 3;
^~~
warning: no debug symbols in executable (-arch x86_64)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment