1 // copyright 2014 the rust project developers. see the copyright
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/copyright.
5 // licensed under the apache license, version 2.0 <license-apache or
6 // http://www.apache.org/licenses/license-2.0> or the mit license
7 // <license-mit or http://opensource.org/licenses/mit>, at your
8 // option. this file may not be copied, modified, or distributed
9 // except according to those terms.
11 // Test that cleanups for the RHS of shorcircuiting operators work.
17 let args = os::args();
19 // Here, the rvalue `~"signal"` requires cleanup. Older versions
20 // of the code had a problem that the cleanup scope for this
21 // expression was the end of the `if`, and as the `~"signal"`
22 // expression was never evaluated, we wound up trying to clean
23 // uninitialized memory.
25 if args.len() >= 2 && args[1] == ~"signal" {
27 unsafe { *(0 as *mut int) = 0; }