Not getting a repeating pattern for garbage value from undefined struct

This is my first post here I am a zig newbie!

On zigling 038/structs2.zig, the comment reads:

// If you tried running the program without adding Zump as mentioned
// above, you get what appear to be "garbage" values. In debug mode
// (which is the default), Zig writes the repeating pattern "10101010"
// in binary (or 0xAA in hex) to all undefined locations to make them
// easier to spot when debugging.

But when I comment out Zump and compile, I do not get said repeating pattern, I get this output:

Compiling: 038_structs2.zig
Checking: 038_structs2.zig
error:
========= expected this output: ==========
Character 1 - G:20 H:100 XP:10
Character 2 - G:10 H:100 XP:20
========= but found: =====================
Character 1 - G:20 H:100 XP:10
Character 2 - G:2863311530 H:170 XP:2863311530
==========================================

So what am I missing here? I feel like I should see something like:

========= but found: =====================
Character 1 - G:20 H:100 XP:10
Character 2 - G:1010101010 H:101 XP:1010101010

2863311530 in decimal is 0xAA... repeating in hexadecimal and 0b1010... repeating in binary. If you want to print it out in hexadecimal or binary you can try swapping out the {} (or {d}) format specifiers for {x} or {b} respectively.

6 Likes