You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package test
import "core:fmt"
import "core:mem"
Stack :: struct(T :typeid)
{
head :int,
elements :[]T,
}
make_stack :: inline proc($T :typeid, len :int, allocator := context.allocator) -> (stack :Stack(T))
{
using stack;
head = 0;
elements = make([]T, len, allocator);
return;
}
make_temp_stack :: inline proc($T :typeid, len :int, allocator := context.temp_allocator) -> Stack(T)
{
return make_stack(T, len, allocator);
}
push_unsafe :: inline proc(using stack :^Stack($T), element :T)
{
#no_bounds_check elements[head] = element;
head += 1;
}
main :: proc() {
using fmt;
arena_slice := make([]byte, mem.megabytes(30));
defer delete(arena_slice);
arena :mem.Arena;
mem.init_arena(&arena, arena_slice);
arena_allocator := mem.arena_allocator(&arena);
context.temp_allocator = arena_allocator;
st := make_temp_stack(u128,32);
push_unsafe(&st, 1);
println("done");
}
Alternatively, this version of main has also been reported to have the issue:
main :: proc() {
using fmt;
st := make_temp_stack(u128,32);
push_unsafe(&st, 1);
println("done");
}
Different optimization levels also affect the behavior. I can get similar code to sometimes work with optimization levels 0, 2, and 3, but not 1, and this code apparently only works with 0.
OS: Windows 10
Odin version: 0bac2445bb4e0e2b8e3b229f79a4bae9dedfdf7
Expected Behavior
The u128 should correctly be put into the specified index of the elements slice in the stack struct.
Because of various noodling I have been doing with that project I have encountered many behaviors that seem related to this that I do not know how to enumerate at this point in time. At one point I was not able to get the stack functions to work unless they were inlined, but it might be working now? I am unsure.
Steps to Reproduce
Run the code excerpts listed in the Context section of this bug report.
Failure Logs
The program will crash without any output.
The text was updated successfully, but these errors were encountered:
Context
Code:
Alternatively, this version of main has also been reported to have the issue:
Different optimization levels also affect the behavior. I can get similar code to sometimes work with optimization levels 0, 2, and 3, but not 1, and this code apparently only works with 0.
OS: Windows 10
Odin version: 0bac2445bb4e0e2b8e3b229f79a4bae9dedfdf7
Expected Behavior
The u128 should correctly be put into the specified index of the elements slice in the stack struct.
Current Behavior
When
push_unsafe
is used with a u128 it crashes.Failure Information (for bugs)
This bug is difficult to explain because it seems to behave wildly differently depending on what else is happening in the code. This project is where it was discovered: https://github.com/John-Minor/Named-Regions-DFA-Regex
Because of various noodling I have been doing with that project I have encountered many behaviors that seem related to this that I do not know how to enumerate at this point in time. At one point I was not able to get the stack functions to work unless they were inlined, but it might be working now? I am unsure.
Steps to Reproduce
Failure Logs
The program will crash without any output.
The text was updated successfully, but these errors were encountered: