Was playing around with https://playground.zigtools.org and noticed that:
const std = @import("std");
const Silly = struct {
a: u64,
pub fn init(a: u32) Silly {
return .{ .a = a * a };
}
};
pub fn main() !void {
const silly = Silly.init(7777777);
std.log.info("{}", .{silly.a});
}
outputs:
RuntimeError: Unreachable code should not be executed (evaluating 'e.exports._start()')
On the other hand, on godbolt the output is more expected:
Program returned: 139
Program stderr
thread 1 panic: integer overflow
/app/example.zig:7:26: 0x11d87bd in init (example.zig)
return .{ .a = a * a };
^
/app/example.zig:12:29: 0x11d7231 in main (example.zig)
const silly = Silly.init(7777777);
^
/cefs/88/88fde13df29428d00d960468_consolidated/compilers_zig_new_naming_0.16.0/lib/std/start.zig:698:59: 0x11d783c in callMain (std.zig)
if (fn_info.params.len == 0) return wrapMain(root.main());
^
/cefs/88/88fde13df29428d00d960468_consolidated/compilers_zig_new_naming_0.16.0/lib/std/start.zig:190:5: 0x11d7211 in _start (std.zig)
asm volatile (switch (native_arch) {
^
Program terminated with signal: SIGSEGV
I'm wondering if this is a bug in Zig's experimental WASM support (and should be reported there) or a problem with the playground?
P.S. Also, for the record, what is the version of Zig that runs on the playground? I see it hardcoded as 0.17.0 (hence builtin.zig_version_string says as much) but I'm not sure which specific development revision it is.
Was playing around with https://playground.zigtools.org and noticed that:
outputs:
On the other hand, on godbolt the output is more expected:
I'm wondering if this is a bug in Zig's experimental WASM support (and should be reported there) or a problem with the playground?
P.S. Also, for the record, what is the version of Zig that runs on the playground? I see it hardcoded as
0.17.0(hencebuiltin.zig_version_stringsays as much) but I'm not sure which specific development revision it is.