You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But if I try to use the struct literal directly in the @bitCast the compiler trips on an assert.
warn("{x}\n", @bitCast(u8, Foo{.value=0xF}));
This is similar to #3010, but when I built zig with #3022 it didn't fix the problem.
Here is the back trace right before it evaluates the assert.
#0 get_abi_alignment (g=0x555558387ad0, type_entry=0x55555e803b60)
at /home/fred/src/zig/src/analyze.cpp:332
#1 0x0000555555e60bcd in get_pointer_to_type_extra (g=0x555558387ad0, child_type=0x55555e803b60,
is_const=false, is_volatile=false, ptr_len=PtrLenSingle, byte_alignment=1,
bit_offset_in_host=0, host_int_bytes=0, allow_zero=false)
at /home/fred/src/zig/src/analyze.cpp:390
#2 0x0000555555df7dbe in ir_resolve_result_raw (ira=0x55555e805f60,
suspend_source_instr=0x55555e804f60, result_loc=0x55555e804b10, value_type=0x55555e803b60,
value=0x0, force_runtime=false, non_null_comptime=true) at /home/fred/src/zig/src/ir.cpp:15475
#3 0x0000555555df7f16 in ir_resolve_result (ira=0x55555e805f60,
suspend_source_instr=0x55555e804f60, result_loc_pass1=0x55555e804b10,
value_type=0x55555e803b60, value=0x0, force_runtime=false, non_null_comptime=true,
allow_discard=true) at /home/fred/src/zig/src/ir.cpp:15498
#4 0x0000555555df8245 in ir_analyze_instruction_resolve_result (ira=0x55555e805f60,
instruction=0x55555e804f60) at /home/fred/src/zig/src/ir.cpp:15551
#5 0x0000555555e1e00c in ir_analyze_instruction_base (ira=0x55555e805f60,
instruction=0x55555e804f60) at /home/fred/src/zig/src/ir.cpp:25714
#6 0x0000555555e1e726 in ir_analyze (codegen=0x555558387ad0, old_exec=0x55555e7dc1b8,
new_exec=0x55555e7dc2a8, expected_type=0x5555590b8240, expected_type_source_node=0x5555583d8460)
at /home/fred/src/zig/src/ir.cpp:25855
#7 0x0000555555e6b6a7 in analyze_fn_ir (g=0x555558387ad0, fn_table_entry=0x55555e7dc150,
return_type_node=0x5555583d8460) at /home/fred/src/zig/src/analyze.cpp:3789
#8 0x0000555555e6bafe in analyze_fn_body (g=0x555558387ad0, fn_table_entry=0x55555e7dc150)
at /home/fred/src/zig/src/analyze.cpp:3876
#9 0x0000555555e6c453 in semantic_analyze (g=0x555558387ad0)
at /home/fred/src/zig/src/analyze.cpp:4008
#10 0x0000555555db5287 in gen_root_source (g=0x555558387ad0)
at /home/fred/src/zig/src/codegen.cpp:8629
#11 0x0000555555db8bca in codegen_build_and_link (g=0x555558387ad0)
at /home/fred/src/zig/src/codegen.cpp:9566
#12 0x0000555555d8c14d in main (argc=9, argv=0x7fffffffd688) at /home/fred/src/zig/src/main.cpp:1207
I tried to debug it myself but I couldn't get farther than figuring out that the type_entry->data->structure.resolve_status of Foo is ResolveStatusUnstarted and guessed that creating a named Foo value first would make it work:
I tried again just now, actually fetched #3022's branch instead of just adding the ! and made sure I was using the right zig before building the my example. However it acts the same as master for me.
Just to make sure it's clear what code I'm talking about since I didn't list the whole thing above:
Ok, that's really weird. All I did when trying to reproduce it was replace the warn line with what you gave later on, without removing the foo_value declaration, and that worked:
Using master the following works:
But if I try to use the struct literal directly in the
@bitCast
the compiler trips on an assert.This is similar to #3010, but when I built zig with #3022 it didn't fix the problem.
Here is the back trace right before it evaluates the assert.
I tried to debug it myself but I couldn't get farther than figuring out that the
type_entry->data->structure.resolve_status
ofFoo
isResolveStatusUnstarted
and guessed that creating a namedFoo
value first would make it work:This does compile, but the result isn't what I expected:
Shouldn't the second one be a
u8
as well? Is there something I'm missing here or is this a side effect of the bug above?The text was updated successfully, but these errors were encountered: