roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.49k stars 315 forks source link

Make testing_roc_alloc align the allocation #7287

Open MatthewJohnHeath opened 2 days ago

MatthewJohnHeath commented 2 days ago

Currently testing_roc_allocin crates/compiler/builtins/bitcode/src/utils.zig ignores the value passed as alignment and always returns a pointer to memory with alignment 1. This caused me a few hours of confusion trying to test an allocation that needed aligning. Ideally, it would align to whatever value is passed (up to that supported by Zig), but allocating with an alignment not known at compile time seems hard (?). Always aligning to 16 and panicking if a higher alignment is requested seems like it would cover all likely cases (without wasting too many bytes)

Anton-4 commented 1 day ago

I started a discussion for this: https://roc.zulipchat.com/#narrow/channel/395097-compiler-development/topic/testing_roc_alloc/near/485604671