Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Assertion failure: `value.type != nullptr` involving @disabled and when

Open Tetralux opened this issue 4 years ago • 1 comments

Windows x64, edbf2bf56f9c3cac0b996ca9f4fdccfe80637929 Odin version output: odin version dev-2021-09:edbf2bf5


I have a debug printing function which is supposed to be a no-op, unless a -define is passed.

The following program works just fine - however, if you remove the when, the compiler crashes with an assertion failure. It also works fine if you -define:DEBUGIT=true.

$ odin build test.odin
src\llvm_backend_general.cpp(536): Assertion Failure: `value.type != nullptr`
package test

import "core:fmt"
import "core:strings"

@(disabled=!#config(DEBUGIT, false))
debug :: proc(format: string, args: ..any) {
    when #config(DEBUGIT, false) { // BUG: remove this when to cause the assertion
        b := strings.make_builder(context.temp_allocator)
        s := fmt.sbprintf(&b, format, ..args)
        fmt.println("[debug]", s)
    }
}


main :: proc() {
    debug("Hi %v", 123)
}

It works fine if you -define:DEBUGIT=true.

Tetralux avatar Sep 28 '21 20:09 Tetralux

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 21:07 github-actions[bot]