odin-lang / Odin

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

Self-referential `offset_of` locks up the compiler. #4498

Open jasonKercher opened 1 week ago

jasonKercher commented 1 week ago

Context

Operating system is irrelevant. I reproduced it on Linux and Windows.

Expected Behavior

Compiler to compile the code as intended or emit an error.

Current Behavior

Appears to deadlock

Failure Information (for bugs)

Debugger says deadlock is at src/types.cpp:3297

Steps to Reproduce

Try to compile:

package main

import "core:fmt"

Cache_Line :: struct {
        next: ^Cache_Line,
        is_foo: b32,
        foos: i32,
        bars: i32,
        pad: [64 - offset_of(Cache_Line, pad)]u8,
}

main :: proc()
{
        c: Cache_Line
        fmt.println(c)
}

Failure Logs

Compiler locks up and needs to be interrupted.