From 7e1dd57395d4400d0ac6d6c31f206ceb1555f544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Fro=C5=82ow?= Date: Mon, 30 Dec 2019 12:19:08 +0100 Subject: [PATCH] Uninitialized _y has value -1 --- src/getting-started/03.00.DEBUG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/getting-started/03.00.DEBUG.md b/src/getting-started/03.00.DEBUG.md index ec103b5..c2935ee 100644 --- a/src/getting-started/03.00.DEBUG.md +++ b/src/getting-started/03.00.DEBUG.md @@ -87,15 +87,15 @@ $1 = 42 $2 = (i32 *) 0x10001fdc (gdb) print _y -$3 = 134219052 +$3 = -1 (gdb) print &_y $4 = (i32 *) 0x10001fd8 ``` As expected, `x` contains the value `42`. -`_y` however, contains the value `134219052` (?). -Because `_y` has not been initialized yet, it contains some garbage value. +`_y` however, contains the value `-1` (?). +Because `_y` has not been initialized yet, it contains `-1`. The command `print &x` prints the address of the variable `x`. The interesting bit here is that GDB output shows the type of the reference: @@ -108,7 +108,7 @@ Instead of printing the local variables one by one, you can also use the `info l ``` (gdb) info locals x = 42 -_y = 134219052 +_y = -1 ``` OK. With another `step`, we'll be on top of the `loop {}` statement: