backend: a union constant in a ternary or builds an ill-typed phi

This commit is contained in:
kalsprite committed 2026-08-19 16:45:58 -07:00
1 parent 97b5078ad5
commit a13a4b418d
3 files changed
+60 -3

No files matched your search

+4
View File
@@ -4605,6 +4605,9 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {
if (is_type_internally_pointer_like(type)) {
incoming_values[0] = LLVMBuildBitCast(p->builder, incoming_values[0], llvm_type, "");
}
// A union constant is built as an anonymous packed struct, which a phi cannot accept
// alongside the named type it results in, even though the two are laid out identically
incoming_values[0] = OdinLLVMBuildTransmute(p, incoming_values[0], llvm_type);
lb_emit_jump(p, done);
lb_start_block(p, else_);
@@ -4614,6 +4617,7 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {
if (is_type_internally_pointer_like(type)) {
incoming_values[1] = LLVMBuildBitCast(p->builder, incoming_values[1], llvm_type, "");
}
incoming_values[1] = OdinLLVMBuildTransmute(p, incoming_values[1], llvm_type);
lb_emit_jump(p, done);
lb_start_block(p, done);