Uninitialized _y has value -1
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user