Rust array corruption?
This file contains 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
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