Skip to content

sizeOf(T) > 0 inconsistent result #4536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Feb 23, 2020 · 1 comment · Fixed by #4552
Closed

sizeOf(T) > 0 inconsistent result #4536

ghost opened this issue Feb 23, 2020 · 1 comment · Fixed by #4552
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@ghost
Copy link

ghost commented Feb 23, 2020

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
LemonBoy added a commit to LemonBoy/zig that referenced this issue Feb 25, 2020
andrewrk pushed a commit that referenced this issue Feb 25, 2020
@andrewrk andrewrk added this to the 0.6.0 milestone Feb 25, 2020
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Feb 25, 2020
@andrewrk
Copy link
Member

The fix is reverted in dad62a7 because it caused #4560. A new test case to cover the regression is added in e75598a.

@andrewrk andrewrk reopened this Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant