aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/sub_on_undefined_value.zig
blob: 5d2510f26324a22642d8085881b5cd120105d331 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
comptime {
    const undef: i64 = undefined;
    const not_undef: i64 = 32;

    // If the rhs is zero, then the other operand is returned, even if it is undefined.
    @compileLog(undef - 0);
    @compileLog(not_undef - 0);

    _ = undef - undef;
}

// error
// backend=stage2
// target=native
//
// :9:17: error: use of undefined value here causes undefined behavior
//
// Compile Log Output:
// @as(i64, undefined)
// @as(i64, 32)