Created
April 29, 2013 14:01
-
-
Save pnkfelix/5481736 to your computer and use it in GitHub Desktop.
example showing when rustc encourages uninitalized variable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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