diff options
| author | 2026-10-15 22:15:38 +0330 | |
|---|---|---|
| committer | 2026-10-15 22:15:38 +0330 | |
| commit | be43babc1886fc5efee898b2a3d0285012e511fb (patch) | |
| tree | b7ae73e7a6d4c896e2c49b7090168ef589b574af /src/runtime | |
| parent | merge work/known-bugs: constant-expression precedence, local const in constan... (diff) | |
definite assignment: reading a local before it is initialized is a compile error (spec 4.1.5, b.1.9)
track linited per local alongside the ownership state; snapshots, exit records and joins carry it, and a join keeps a local set only when every reaching path set it. x = e, a declaration initializer, &x (out-parameter), a full array initializer, or using an aggregate as an address set a local; field and element writes do not set the aggregate. while/for bodies that may run zero times do not count; do/while does. compiler, runtime, std, actor and lsp sources initialize the locals the rule flagged; zc0 accepts = {} brace lists (zeroed). tests: tests/errors/uninit_*.zc, tests/conformance/4-statements/uninit_*.zc
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/rt.zc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/rt.zc b/src/runtime/rt.zc index 4f96320..a79387f 100644 --- a/src/runtime/rt.zc +++ b/src/runtime/rt.zc @@ -182,7 +182,7 @@ int put_s(char* s) { // write the decimal form of a number, with a minus sign for a negative one. // the smallest integer is handled as its own case. int put_n(int n) { - char[24] b; int i = 0; + char[24] b = {}; int i = 0; if (n < 0) { put_c('-'); n = 0 - n; } if (n < 0) { put_s("9223372036854775808"); return 0; } while (1) { b[i++] = '0' + n % 10; n = n / 10; if (!n) break; } @@ -340,7 +340,7 @@ int s_to_n(bstr s) { } // a new packed byte string holding the decimal form of n. bstr n_to_s(int n) { - word[24] b; int i = 0, j = 0, neg = 0; bstr p; char* t; + word[24] b = {}; int i = 0, j = 0, neg = 0; bstr p; char* t; if (!n) { p = new_s(1); sput(p, 0, '0'); sput(p, 1, 0); return p; } if (n < 0) { neg = 1; n = 0 - n; } if (n < 0) { @@ -431,7 +431,7 @@ const int F_HASDROP = 16, F_DROPPED = 32, F_FINAL = 64, F_CYCLE = 128; // F_CYCL int o3_depth, gc_pending, gc_cyc; // gc_cyc: the last sweep found a cycle with drops to run // flags live in these bits; the size class is above them. const int F_LOW = 65535; -int hbump; word[32] freel; int gc_runs, gc_freed, gc_auto = 1; +int hbump; word[32] freel = {}; int gc_runs, gc_freed, gc_auto = 1; // block walks and new chunks stop here. int hstop; // while nonzero, balloc will not return a block overlapping this range. @@ -1201,7 +1201,7 @@ int line_of(word b, int a) { } // write the hexadecimal form of a number int put_hex(int n) { - char[20] b; int i = 0, d; + char[20] b = {}; int i = 0, d; put_s("0x"); if (!n) { put_c('0'); return 0; } while (n && i < 16) { d = n & 15; if (d < 10) b[i++] = '0' + d; else b[i++] = 'a' + d - 10; n = n >> 4; } |
