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
My (possibly incorrect) understanding was that since this is a global undefined var, it shouldn't be fully allocated at comptime but rather it should be specified in the .bss section of the object.
The zig cc compiler can build an equivalent C program:
mike@budgie:~/src/zigxperiments$ cat static-allocation.c
char memory[4294967296];
int main() {
memory[0] = 1;
return 0;
}
mike@budgie:~/src/zigxperiments$ zig cc static-allocation.c
mike@budgie:~/src/zigxperiments$
Smaller amounts of memory will compile successfully but since they're being allocated at compile time the additional memory usage can result in OOM conditions. These examples were all on Linux.
Expected Behavior
I expected the compiler to be able to build the exe with an entry in the .bss section. I don't think this memory needs to actually be allocated at comptime.
Actual Behavior
The compiler attempts to allocate the specified amount of memory at comptime and crashes if the amount of memory is too large.
The text was updated successfully, but these errors were encountered:
mikemar10
added
the
bug
Observed behavior contradicts documented or intended behavior
label
Dec 6, 2021
andrewrk
added
the
stage1
The process of building from source via WebAssembly and the C backend.
label
Dec 6, 2021
Zig Version
0.9.0-dev.1903+2af94e76a
Steps to Reproduce
Attempting to compile this source code causes a panic at compile time:
My (possibly incorrect) understanding was that since this is a global undefined var, it shouldn't be fully allocated at comptime but rather it should be specified in the .bss section of the object.
The zig cc compiler can build an equivalent C program:
Smaller amounts of memory will compile successfully but since they're being allocated at compile time the additional memory usage can result in OOM conditions. These examples were all on Linux.
Expected Behavior
I expected the compiler to be able to build the exe with an entry in the .bss section. I don't think this memory needs to actually be allocated at comptime.
Actual Behavior
The compiler attempts to allocate the specified amount of memory at comptime and crashes if the amount of memory is too large.
The text was updated successfully, but these errors were encountered: