mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00: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.
27 lines
691 B
Zig
27 lines
691 B
Zig
//! []One -> []Two (small to big, divides neatly)
|
|
|
|
const One = u8;
|
|
const Two = [2]u8;
|
|
|
|
/// A runtime-known value to prevent these safety panics from being compile errors.
|
|
var rt: u8 = 0;
|
|
|
|
pub fn main() void {
|
|
const in: []const One = &.{ 1, 0, rt };
|
|
const out: []const Two = @ptrCast(in);
|
|
_ = out;
|
|
std.process.exit(1);
|
|
}
|
|
|
|
pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
|
|
if (std.mem.eql(u8, message, "slice length '3' does not divide exactly into destination elements")) {
|
|
std.process.exit(0);
|
|
}
|
|
std.process.exit(1);
|
|
}
|
|
|
|
const std = @import("std");
|
|
|
|
// run
|
|
// backend=selfhosted,llvm
|
|
// target=x86_64-linux,aarch64-linux
|