Skip to content

Commit 87b76af

Browse files
committed
Fix assertion failure due to the case list not being sorted properly on duplicate case values
1 parent 8a6693f commit 87b76af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

source/compiler/sc3.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,8 +1768,11 @@ static int hier2(value *lval)
17681768
check_tagmismatch(swtag,csetag,TRUE,-1);
17691769
while (++val<=end) {
17701770
casecount++;
1771-
csp=newval;
1772-
cse=newval->next;
1771+
/* find the new insertion point */
1772+
for (csp=NULL, cse=caselist.first;
1773+
cse!=NULL && cse->value<val;
1774+
csp=cse, cse=cse->next)
1775+
/* nothing */;
17731776
if (cse!=NULL && cse->value==val)
17741777
error(40,val); /* duplicate "case" label */
17751778
assert(csp!=NULL && csp->next==cse);

0 commit comments

Comments
 (0)