Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler panic involving casts #4718

Open
marcs-feh opened this issue Jan 19, 2025 · 0 comments
Open

Compiler panic involving casts #4718

marcs-feh opened this issue Jan 19, 2025 · 0 comments

Comments

@marcs-feh
Copy link
Contributor

marcs-feh commented Jan 19, 2025

Context

I'm currently making set of custom bindings of the popular library FreeType2 and as I was porting its types to more odin-friendly structures I've stumbled upon a compiler bug

Odin:    dev-2025-01
OS:      Arch Linux, Linux 6.6.56-1-lts
CPU:     AMD Ryzen 3 3200G with Radeon Vega Graphics    
RAM:     15922 MiB
Backend: LLVM 18.1.6

Expected Behavior

Should ideally work as the values can be bit-wise converted and are known at compile time. But a proper compiler error is also acceptable. Originally I tried using a transmute but that caused a compiler message about the value not being constant.

Current Behavior

The compiler panics

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

package bug

Encoding :: enum u32 {
   NONE = 0,
   MS_SYMBOL = cast(u32)[4]u8{'s', 'y', 'm', 'b'},
   UNICODE   = cast(u32)[4]u8{'u', 'n', 'i', 'c'},

   SJIS      = cast(u32)[4]u8{'s', 'j', 'i', 's'},
   PRC       = cast(u32)[4]u8{'g', 'b', ' ', ' '},
   BIG5      = cast(u32)[4]u8{'b', 'i', 'g', '5'},
   WANSUNG   = cast(u32)[4]u8{'w', 'a', 'n', 's'},
   JOHAB     = cast(u32)[4]u8{'j', 'o', 'h', 'a'},

    // For backward compatibility
    GB2312     = PRC,
    MS_SJIS    = SJIS,
    MS_GB2312  = PRC,
    MS_BIG5    = BIG5,
    MS_WANSUNG = WANSUNG,
    MS_JOHAB   = JOHAB,

    ADOBE_STANDARD = cast(u32)[4]u8{'A', 'D', 'O', 'B'},
    ADOBE_EXPERT   = cast(u32)[4]u8{'A', 'D', 'B', 'E'},
    ADOBE_CUSTOM   = cast(u32)[4]u8{'A', 'D', 'B', 'C'},
    ADOBE_LATIN_1  = cast(u32)[4]u8{'l', 'a', 't', '1'},

    OLD_LATIN_2 = cast(u32)[4]u8{ 'l', 'a', 't', '2'},

    APPLE_ROMAN = cast(u32)[4]u8{ 'a', 'r', 'm', 'n'},
}

Failure Logs

src/exact_value.cpp(1020): Panic: Invalid comparison

Edit: I copied the older version of the code, the update one still presents the same problem though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant