odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.1k stars 550 forks source link

odin build asserts on ill-formed bitfields #3811

Closed cmourglia closed 5 days ago

cmourglia commented 5 days ago

Context

Odin compiler did hit an assert because of a typo inside a bitfield. When using {.1} (considered as a float) instead of (the correct in this case {._1}) the compiler crashes (asserts), complaining it expected an integer and got a float instead.

Odin:    dev-2024-06:94ec64792
OS:      Windows 11 Professional (version: 23H2), build 22631.3737
CPU:     11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz
RAM:     32637 MiB
Backend: LLVM 17.0.1

Expected Behavior

The compiler should report an error because of the ill-formed bitfield.

Current Behavior

The compiler hits an assert, then crashes.

Failure Information (for bugs)

The hit assert is the following:

D:\odin\src\check_expr.cpp(9822): Assertion Failure: tav.value.kind == ExactValue_Integer

Steps to Reproduce

Compiling the following code reproduces the error:

package test

import vk "vendor:vulkan"

main :: proc()
{
    imageInfo := vk.ImageCreateInfo {
        samples = {.1}
    }
}
Feoramund commented 5 days ago

I'm unable to reproduce this on Linux with the latest commit. I see from your report you're on 94ec64792. I also checked line 9822 in check_expr.cpp per the assert, and I could not find an assert on that line. Are you able to test this with a more up-to-date version of the Odin compiler?

cmourglia commented 5 days ago
Error: Cannot convert untyped value '.1' to 'SampleCountFlag' from 'untyped float'
        samples     = {.1},

Looks like someone (you, in fact) caught that before me indeed ! Closing then.