mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 07:44:51 +01:00
backend=auto (now the default if backend is omitted) means to let the compiler pick whatever backend it wants as the default. This is important for platforms where we don't yet have a self-hosted backend, such as loongarch64. Also purge a bunch of redundant target=native.
29 lines
905 B
Zig
29 lines
905 B
Zig
export fn entry1() void {
|
|
const spartan_count: u16 = 300;
|
|
const byte: u8 = @intCast(spartan_count);
|
|
_ = byte;
|
|
}
|
|
export fn entry2() void {
|
|
const spartan_count: u16 = 300;
|
|
const byte: u8 = spartan_count;
|
|
_ = byte;
|
|
}
|
|
export fn entry3() void {
|
|
var spartan_count: u16 = 300;
|
|
var byte: u8 = spartan_count;
|
|
_ = .{ &spartan_count, &byte };
|
|
}
|
|
export fn entry4() void {
|
|
var signed: i8 = -1;
|
|
var unsigned: u64 = signed;
|
|
_ = .{ &signed, &unsigned };
|
|
}
|
|
|
|
// error
|
|
//
|
|
// :3:31: error: type 'u8' cannot represent integer value '300'
|
|
// :8:22: error: type 'u8' cannot represent integer value '300'
|
|
// :13:20: error: expected type 'u8', found 'u16'
|
|
// :13:20: note: unsigned 8-bit int cannot represent all possible unsigned 16-bit values
|
|
// :18:25: error: expected type 'u64', found 'i8'
|
|
// :18:25: note: unsigned 64-bit int cannot represent all possible signed 8-bit values
|