remove seq[T] setLen undefined behavior (#21582)

remove seq[T] setLen UB

(cherry picked from commit 51ced0d684)
This commit is contained in:
tersec
2023-03-29 10:00:00 +00:00
committed by narimiran
parent 65a7496e51
commit 30737676de

View File

@@ -1864,7 +1864,7 @@ proc genSetLengthSeq(p: BProc, e: PNode, d: var TLoc) =
initLoc(call, locCall, e, OnHeap)
if not p.module.compileToCpp:
const setLenPattern = "($3) #setLengthSeqV2(&($1)->Sup, $4, $2)"
const setLenPattern = "($3) #setLengthSeqV2(($1)?&($1)->Sup:NIM_NIL, $4, $2)"
call.r = ropecg(p.module, setLenPattern, [
rdLoc(a), rdLoc(b), getTypeDesc(p.module, t),
genTypeInfoV1(p.module, t.skipTypes(abstractInst), e.info)])