Skip to content
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

stage2: Bitcast allowed between types of different sizes #13214

Closed
topolarity opened this issue Oct 18, 2022 · 0 comments
Closed

stage2: Bitcast allowed between types of different sizes #13214

topolarity opened this issue Oct 18, 2022 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@topolarity
Copy link
Contributor

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.

@topolarity topolarity added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Oct 18, 2022
Vexu added a commit to Vexu/zig that referenced this issue Oct 18, 2022
@Vexu Vexu added this to the 0.10.0 milestone Oct 18, 2022
Vexu added a commit to Vexu/zig that referenced this issue Oct 18, 2022
Vexu added a commit to Vexu/zig that referenced this issue Oct 18, 2022
Vexu added a commit to Vexu/zig that referenced this issue Oct 18, 2022
@Vexu Vexu closed this as completed in 13897be Oct 21, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 28, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 28, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 28, 2022
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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

2 participants