这是indexloc提供的服务,不要输入任何密码
Skip to content

format string + ternary operation = failure in LLVM backend #5502

@Carlyle-Foster

Description

@Carlyle-Foster
package test_case_1

import "core:fmt"

main :: proc(){
    fmt.printfln("{}", true ? any(52) : any("blah"))
}

result from odin build test_case_1:

src/llvm_backend_const.cpp(769): Assertion Failure: `is_type_string(original_type)` 
Illegal instruction (core dumped)
package test_case_2

import "core:fmt"

main :: proc(){
    fmt.printfln("{}", true ? any(52) : any(42))
}

odin build test_case_2:

LLVM CODE GEN FAILED FOR PROCEDURE: test_case_2::main
define void @"test_case_2::main"(ptr noalias nocapture nonnull %__.context_ptr) {
decls:
  %0 = alloca { ptr, i64 }, align 8
  %1 = alloca [16 x i8], align 16
  br label %entry

entry:                                            ; preds = %decls
  br i1 true, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  br label %if.done

if.else:                                          ; preds = %entry
  br label %if.done

if.done:                                          ; preds = %if.else, %if.then
  %2 = phi %..any [ false, %if.then ], [ false, %if.else ]
  call void @llvm.memset.inline.p0.i64(ptr %0, i8 0, i64 16, i1 false)
  call void @llvm.memset.inline.p0.i64(ptr %1, i8 0, i64 16, i1 false)
  %3 = getelementptr [1 x %..any], ptr %1, i64 0, i64 0
  store %..any %2, ptr %3, align 8
  %4 = getelementptr [1 x %..any], ptr %1, i64 0, i64 0
  %5 = getelementptr inbounds { ptr, i64 }, ptr %0, i32 0, i32 0
  store ptr %4, ptr %5, align 8
  %6 = getelementptr inbounds { ptr, i64 }, ptr %0, i32 0, i32 1
  store i64 1, ptr %6, align 8
  %7 = load { ptr, i64 }, ptr %0, align 8
  %8 = call i64 @"fmt::printfln"(%..string { ptr @"csbs$test_case_2-test_case_2$0", i64 2 }, { ptr, i64 } %7, i8 1, ptr %__.context_ptr)
  ret void
}




PHI node operands are not the same type as the result!
  %2 = phi %..any [ false, %if.then ], [ false, %if.else ]

odin report (paraphrased) =

        Odin:    dev-2025-07:a93d3503b
        OS:      Linux Mint 22, Linux 6.8.0-62-generic
        CPU:     12th Gen Intel(R) Core(TM) i5-12400F
        RAM:     15825 MiB
        Backend: LLVM 18.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions