-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.
Milestone
Description
const std = @import("std");
fn foo(a: u32, b: u32) u32 {
return a + b;
}
fn bar() void {
std.debug.warn("bar\n");
}
pub fn main() void {
std.debug.warn("{}, {}\n", @frameSize(foo), @as(usize, @sizeOf(@Frame(foo))));
std.debug.warn("{}, {}\n", @frameSize(bar), @as(usize, @sizeOf(@Frame(bar))));
}gives an output similar to
$ zig run framesize.zig
10416984888683040912, 48
10416984888683040912, 32
tested on windows and linux, x64.
LLVM-IR:
; Function Attrs: nobuiltin noinline noreturn nounwind uwtable alignstack(16)
define void @WinMainCRTStartup() local_unnamed_addr #3 !dbg !858 {
Entry:
%0 = load i64, i64* getelementptr (i64, i64* bitcast (i32 (i32, i32)* @foo to i64*), i64 -1), align 8, !dbg !863
tail call fastcc void @std.debug.warn(i64 %0, i64 48) #5, !dbg !878
%1 = load i64, i64* getelementptr (i64, i64* bitcast (void ()* @bar to i64*), i64 -1), align 8, !dbg !879
tail call fastcc void @std.debug.warn(i64 %1, i64 32) #5, !dbg !880
tail call void @ExitProcess(i32 0), !dbg !881
unreachable, !dbg !883
}Reading the documentation, they should be equal.
Also the doc is not up-to-date as it says @frameSize takes no parameter.
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviormiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.