I'm doing some bit field work and I've encountered a roadblock.
My application could use a struct with some field that are unions like TestStruct:
const std = @import("std");
const TestStruct = packed struct {
a: u32,
b: packed union {
b1: u32,
b2: i32,
}
};
pub fn main() void{
const c = TestStruct{.a = 10, .b = .{.b2= -10}};
std.debug.print("{}\n", .{c.b.b2});
}
Howevere compiling it gives some LLVM errors:
LLVM Emit Object... LLVM ERROR: Unsupported expression in static initializer: zext (i32 bitcast ({ i32 } { i32 -10 } to i32) to i64)
Am I missing something?
Also if I remove packed from the struct it compiles fine.