Skip to content

Instantly share code, notes, and snippets.

@i80and
Created August 22, 2012 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save i80and/3426705 to your computer and use it in GitHub Desktop.
Save i80and/3426705 to your computer and use it in GitHub Desktop.
Rust array corruption?
struct Element {
vals: &[float];
}
impl Element {
fn test() {
// Prints a random value close to, but not exactly equal to, 0.
// e.g. 9.52676e-317, 1.43533e-316
// Optimization flags make it exactly 0.
log(info, self.vals[0]);
assert(self.vals[0] == 1.0); // Fails
assert(self.vals[1] == 1.0);
assert(self.vals[2] == 1.0);
assert(self.vals[3] == 1.0);
}
}
fn Element() -> Element {
return Element {
vals: &[1.0, 1.0, 1.0, 1.0]
};
}
fn main() {
let sprite = Element();
sprite.test();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment