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

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

pub fn main() void {
    var f = Foo{ .int = 42 };
    bar(&f);
}

fn bar(f: *Foo) void {
    f.float = 12.34;
    std.debug.print("value: {}\n", .{f.float});
}

// exe=fail