wcc: loop-label stack guards its depth loudly, both stages
wwstage's unguarded loop-label push wrote out of bounds at depth 17 (compiler-heap corruption); cstage guarded but emitted a wrong break target. Loud cap error at the limit, both stages, agreeing wording.
This commit is contained in:
@@ -14282,11 +14282,13 @@ cgstmt(Cg *c, Node *n, Local **locals, int *frame)
|
||||
* continue. Dedicated `rpost` label; bootstrap-NEUTRAL (no
|
||||
* range-form continue callers in lib/ or selfhost/). */
|
||||
char *rpost = mklabel(c, "rpost");
|
||||
if (nloops < LOOP_MAX) {
|
||||
loop_cont[nloops] = rpost;
|
||||
loop_brk[nloops] = end;
|
||||
nloops++;
|
||||
}
|
||||
/* #42: at the cap, fail loud rather than silently push a wrong
|
||||
* break/continue target (the ww twin in cgenstmt.ww guards too). */
|
||||
if (nloops >= LOOP_MAX)
|
||||
fatal("cgen: loop nesting too deep");
|
||||
loop_cont[nloops] = rpost;
|
||||
loop_brk[nloops] = end;
|
||||
nloops++;
|
||||
label(c, loop);
|
||||
ins2(c, A_MOVQ, amem(D_BP, ioff), areg(D_AX));
|
||||
ins2(c, A_MOVQ, amem(D_BP, loff), areg(D_BX));
|
||||
@@ -14430,11 +14432,13 @@ cgstmt(Cg *c, Node *n, Local **locals, int *frame)
|
||||
ins2(c, A_CMPQ, aimm(0), areg(D_AX));
|
||||
ins1(c, A_JE, abranch(natural_exit));
|
||||
}
|
||||
if (nloops < LOOP_MAX) {
|
||||
loop_cont[nloops] = cont_target;
|
||||
loop_brk[nloops] = end;
|
||||
nloops++;
|
||||
}
|
||||
/* #42: at the cap, fail loud rather than silently push a wrong
|
||||
* break/continue target (the ww twin in cgenstmt.ww guards too). */
|
||||
if (nloops >= LOOP_MAX)
|
||||
fatal("cgen: loop nesting too deep");
|
||||
loop_cont[nloops] = cont_target;
|
||||
loop_brk[nloops] = end;
|
||||
nloops++;
|
||||
cgstmt(c, n->body, locals, frame);
|
||||
if (nloops > 0) nloops--;
|
||||
if (n->rhs) {
|
||||
|
||||
Reference in New Issue
Block a user