Skip to content

stage2 can't load elements from arrays in structs #12236

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
Vexu opened this issue Jul 25, 2022 · 1 comment
Closed

stage2 can't load elements from arrays in structs #12236

Vexu opened this issue Jul 25, 2022 · 1 comment
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@Vexu
Copy link
Member

Vexu commented Jul 25, 2022

test {
    const Entry = packed struct {
        unique_partition_guid: [2]u64,
    };
    var foo: Entry = .{ .unique_partition_guid = .{ 0, 0 }};
    // if ((&foo.unique_partition_guid).*[0] != 0) unreachable; // works
    if (foo.unique_partition_guid[0] != 0) unreachable; // assertion failure
}
thread 18003 panic: reached unreachable code
/home/vexu/Documents/zig/zig/lib/std/debug.zig:281:14: 0x6d0268 in std.debug.assert (zig)
    if (!ok) unreachable; // assertion failure
             ^
/home/vexu/Documents/zig/zig/src/codegen/llvm.zig:5178:19: 0xf2d641 in codegen.llvm.FuncGen.airStructFieldVal (zig)
            assert(!isByRef(field_ty));
                  ^
/home/vexu/Documents/zig/zig/src/codegen/llvm.zig:4162:64: 0xeffb14 in codegen.llvm.FuncGen.genBody (zig)
                .struct_field_val => try self.airStructFieldVal(inst),
                                                               ^

Could be related to #12215 since both are caused by the way array access is handled.

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. backend-llvm The LLVM backend outputs an LLVM IR Module. labels Jul 25, 2022
@Vexu Vexu added this to the 0.10.0 milestone Jul 25, 2022
@Vexu
Copy link
Member Author

Vexu commented Aug 7, 2022

Arrays are no longer allowed in packed structs.

@Vexu Vexu closed this as completed Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-llvm The LLVM backend outputs an LLVM IR Module. bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

1 participant