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
I expected the variables to be placed into volatile memory like the .data section. However, in my case it was placed in .rodata and it kept my counter from counting.
The text was updated successfully, but these errors were encountered:
If you want your global to have an explicit type, the solution is to specify it like you in your second code or like this:
pubvarTestA: Test_t= .{.b=100};
Vexu
added
question
No questions on the issue tracker, please.
and removed
bug
Observed behavior contradicts documented or intended behavior
labels
Sep 12, 2024
you might expect the struct even if it's anonymous to be mutable. Should it at least be a compiler error that a const was passed to a function mutating it without a @constCast? It is a segfault at runtime from trying to mutate .rodata instead.
Edit: Apologies, I didn't realize the issue was closed because it is solved by an accepted proposal and not because the behavior is intended.
Zig Version
0.13.0
Steps to Reproduce and Observed Behavior
So i was debugging a variable in my code, because it was supposed to be incrementing. it wasn't.
I reduced the problem into this code which compiles: https://godbolt.org/z/886c9xWrn
I thought this would add 1 to the TestA.a but it cant. because its constant!
It can be fixed by expliclty setting TestA's type:
Looking at the LLVM IR:
Expected Behavior
I expected the variables to be placed into volatile memory like the .data section. However, in my case it was placed in .rodata and it kept my counter from counting.
The text was updated successfully, but these errors were encountered: