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
unreachable: /deps/zig/src/codegen.cpp:gen_const_val_ptr:6010 #2431
Labels
Milestone
Comments
andrewrk
added
the
bug
Observed behavior contradicts documented or intended behavior
label
May 5, 2019
57ec183 didn't fix double panic caused by |
I attempted to isolate this and got to: const std = @import("std");
const some_cond = false;
const My_Vla_Struct = struct {
x: if (some_cond) i32 else void,
const Self = @This();
pub fn usefulMethod(self: *Self) void {
// ...
}
// object is followed by variable length array
};
const ListType = std.TailQueue(My_Vla_Struct);
fn newNode(allocator: *std.mem.Allocator, extra_size: usize) !*ListType.Node {
const node_ptr = try allocator.alignedAlloc(u8, @alignOf(ListType.Node), @sizeOf(ListType.Node) + extra_size);
return @ptrCast(*ListType.Node, node_ptr.ptr);
}
test "vla" {
const node = try newNode(std.debug.global_allocator, 10);
// const vla_ptr = @ptrCast([*]u8, &node.data); // zig: /build/zig/src/zig-0.4.0/src/codegen.cpp:6083: LLVMOpaqueValue* gen_const_val(CodeGen*, ConstExprValue*, const char*): Assertion `type_has_bits(type_entry)' failed.
// const vla_ptr = @ptrToInt(&node.data); // error: pointer to size 0 type has no address
const data = &node.data;
data.usefulMethod();
// const vla_ptr = @ptrToInt(data); // error: pointer to size 0 type has no address
// const vla_ptr = @ptrCast([*]u8, data); // unreachable: /build/zig/src/zig-0.4.0/src/codegen.cpp:gen_const_val_ptr:5956
} Related to #173 |
Fixed in master. I'm pretty sure this is covered by another test case. |
The reduced test case above (uncomment the commented lines) still hit compiler bugs for me |
Oops, my mistake. Good catch. |
daurnimator
added
the
stage1
The process of building from source via WebAssembly and the C backend.
label
Dec 22, 2019
LemonBoy
added a commit
to LemonBoy/zig
that referenced
this issue
Dec 30, 2019
LemonBoy
added a commit
to LemonBoy/zig
that referenced
this issue
Dec 30, 2019
andrewrk
pushed a commit
that referenced
this issue
Dec 30, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it's being caused by the following snippet:
The text was updated successfully, but these errors were encountered: