Skip to content

stage2: Bitcast allowed between types of different sizes #13214

@topolarity

Description

@topolarity

Zig Version

0.10.0-dev.4430+99c3578f

Steps to Reproduce

test {
    const T = extern struct{ i: u64 = 0, x: u16 = 0}; 
    var x = T{};
    //_ = @bitCast(u128, x); // error on stage2
    _ = @bitCast(u80, x); // error on stage1
}

Expected Behavior

I'd expect the @bitCast to be with respect to the actual layout size of the struct, not the sum of the packed size of its fields.

Actual Behavior

Cast is allowed to u80, but not u128.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions