Closed
Description
trans codegen feeds the zeroed discriminant back into match in a loop
Some examples, courtesy of @eddyb and @dotdash
fn main() {
let mut result = Box::new(42);
let mut i = 0;
loop {
match result {
x => {
println!("A>>> {:p}", &*x);
println!("A: {:?}", x);
result = Box::new(42);
if i > 10 { break; }
i += 1;
}
}
}
}
playpen here yields:
A>>> 0x7fedb4423008
A: 42
A>>> 0x0
playpen: application terminated abnormally with signal 4 (Illegal instruction)
Another one, courtesy of @eddyb:
fn main() {
let mut result = (Box::new(12), 34);
// Run in a loop to demonstrate the zeroing:
let mut i = 0;
while i < 4 {
match result {
x => {
println!("{:p} {}", &*x.0, x.1);
result = (Box::new(12), 34);
i += 1;
}
}
}
}
playpen yields:
0x7f05c5823008 34
0x0 0
0x0 0
0x0 0
Metadata
Metadata
Assignees
Labels
No labels