Skip to content

sizeOf(T) > 0 inconsistent result #4536

Closed
@ghost

Description

Similar to #4527 but not quite the same? alignOf doesn't have this problem.

const std = @import("std");

pub fn main() void {
    std.debug.warn("immediate > 0: {}\n", .{ @sizeOf(*u0) > 0 });
    std.debug.warn("immediate > 0.01: {}\n", .{ @sizeOf(*u0) > 0.01 });

    f(*u0);
}

pub fn f(comptime T: type) void {
    std.debug.warn("in function > 0: {}\n", .{ @sizeOf(T) > 0 });
    std.debug.warn("in function > 0.01: {}\n", .{ @sizeOf(T) > 0.01 });
}
immediate > 0: false
immediate > 0.01: false
in function > 0: true
in function > 0.01: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions