-
-
Notifications
You must be signed in to change notification settings - Fork 758
Compiler failure when transmuting png.load_from_file() output in a global enumerated array #5133
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
Comments
You may want to retry with I run it like this, and your code hasn't caused the compiler to crash once. @echo off
odin build . -vet -vet-tabs -strict-style -vet-style -warnings-as-errors -disallow-do -out:scratch.exe -o:none
IF %ERRORLEVEL% NEQ 0 (
echo Error %ERRORLEVEL%
) ELSE (
scratch.exe
) Rewriting it this way works consistently. package a_potential_bug
import "core:fmt"
import "core:image/png"
import "core:slice"
@(init)
initialize_array :: proc() {
img := png.load_from_file(ODIN_ROOT + "/tests/core/assets/PNG/basi0g01.png") or_else nil // Tested with 64x64 pixel PNG file.
if img == nil {
return
}
global_enumerated_array[.A] = slice.reinterpret([]u32, img.pixels.buf[:])
global_enumerated_array[.B] = slice.reinterpret([]u32, img.pixels.buf[:])
}
Some_Enum :: enum int {
A,
B,
}
global_enumerated_array: [Some_Enum][]u32
main :: proc() {
fmt.println(len(global_enumerated_array))
} |
Epic, thanks @Kelimion - that solves the problem I've been having. Will keep |
One trick is to use a build.bat/sh that uses |
And you may also want to add a |
Noted, thanks for the good advice. The absence of |
Context
The program uses
core:image/png
to load a 64x64 pixel image with thepng.load_from_file()
procedure.The bytes buffer
IMG.pixels.buf[:]
is transmuted to a[]u32
slice and added to the global enumerated array's contents.Expected Behavior
Should always be able to compile and then print the length of the array (equal to
2
) to the console when usingodin run .
Current Behavior
Compilation fails most of the time.
Does however rarely manage to compile and successfully print
2
?Failure Information (for bugs)
Steps to Reproduce
some_image.png
png image which is 64x64 pixels in resolution (P.S. I did not test other resolutions).odin run .
Failure Logs
The console output is usually:
C:WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command odin run ." terminated with exit code: 1.
.The text was updated successfully, but these errors were encountered: