In case anyone is following along, I updated the example to better demonstrate where consts end up in memory: godbolt.org/z/jM75hf5b9.
I don't know whether Zig provides a way to check what kind of memory a pointer points to, or if it exposes sections' addresses (eg. gcc's end, edata and etext), but note how get_ptr_static basically returns the address of an unnamed label, which is before the heap (and way before the stack, which grows downwards).
For further actions, you may consider blocking this person and/or reporting abuse
I believe all consts end up on static data sections, not only strings.
Check it out on Godbolt.
Uh, interesting, I'll investingate a little bit and edit the wording. Thanks for pointing that out!
Cheers!
In case anyone is following along, I updated the example to better demonstrate where
const
s end up in memory: godbolt.org/z/jM75hf5b9.I don't know whether Zig provides a way to check what kind of memory a pointer points to, or if it exposes sections' addresses (eg. gcc's
end
,edata
andetext
), but note howget_ptr_static
basically returns the address of an unnamed label, which is before the heap (and way before the stack, which grows downwards).