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

Assertion failure in const_ptr_pointee_unchecked_no_isf #10024

Open
nmeum opened this issue Oct 24, 2021 · 0 comments
Open

Assertion failure in const_ptr_pointee_unchecked_no_isf #10024

nmeum opened this issue Oct 24, 2021 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@nmeum
Copy link
Contributor

nmeum commented Oct 24, 2021

Zig Version

0.9.0-dev.1444+e2a2e6c14

Steps to Reproduce

Attempt to run the following with zig test:

const std = @import("std");
const expect = std.testing.expect;

pub const Header = packed struct {
    version: u2,
    type: u2,
    token_len: u4,
    code: u8,
    message_id: u16,
};

test "test packed struct" {
    const buf: []const u8 = &[_]u8{ 80, 3, 121, 80 };

    const w = buf[0..@sizeOf(Header)];
    const hdr = @ptrCast(*const Header, w);

    try expect(hdr.version == 1);
}

Expected Behavior

No compiler crash.

Actual Behavior

A compiler crash:

$ zig test test.zig
Assertion failed at /home/vsts/work/1/s/src/stage1/ir.cpp:564 in const_ptr_pointee_unchecked_no_isf. This is a bug in the Zig compiler.thread 19566 panic:
Unable to dump stack trace: debug info stripped
Aborted
@nmeum nmeum added the bug Observed behavior contradicts documented or intended behavior label Oct 24, 2021
@andrewrk andrewrk added the stage1 The process of building from source via WebAssembly and the C backend. label Nov 20, 2021
@andrewrk andrewrk added this to the 0.10.0 milestone Nov 20, 2021
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

No branches or pull requests

2 participants