aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/undefined_active_union_field.zig
blob: 494a0d70d288e7c5999bca6ed9b6ef5821c65051 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const std = @import("std");

const Foo = union {
    float: f32,
    int: u32,
};

pub fn main() void {
    var f = Foo{ .int = 42 };
    f = Foo{ .float = undefined };
    bar(&f);
    std.debug.print("value: {}\n", .{f.float});
}

fn bar(f: *Foo) void {
    f.float = 12.34;
}

// exe=succeed