diff --git a/examples/bare0.rs b/examples/bare0.rs index 4ab8495d5c9e6e58a2b5df276363987db82548c8..f65ca9b87971be6d8e8b2384db88fdedb2898cfe 100644 --- a/examples/bare0.rs +++ b/examples/bare0.rs @@ -21,9 +21,9 @@ fn main() { let mut x = unsafe { X }; loop { - x += 1; + x = x.wrapping_add(1); unsafe { - X += 1; + X = X.wrapping_add(1); Y = X; assert!(x == X && X == Y); } @@ -70,10 +70,29 @@ fn main() { // 3. change += opertions to wrapping_add // place a breakpoint at line 22 // load and run the progam, what happens -// ** your answer here ** +// +// Breakpoint 2, bare0::main () at examples/bare0.rs:24 +// 24 x = x.wrapping_add(1); +// (gdb) print x +// $55 = 4294967295 +// (gdb) next +// 26 X += 1; +// (gdb) print x +// $56 = 0 // // now continue exectution, what happens -// ** your answer here ** +// +// (gdb) print bare0::X +// $69 = 4294967295 +// (gdb) next +// 27 Y = X; +// (gdb) print bare0::X +// $70 = 0 +// (gdb) c +// Continuing. +// +// Breakpoint 2, bare0::main () at examples/bare0.rs:24 +// 24 x = x.wrapping_add(1); // // commit your answers (bare0_3) //