diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-04-04 18:18:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-04 12:18:43 +0200 |
commit | 3575f2bf9ccdabe5fa1fcade086ef0c11adc67b5 (patch) | |
tree | 73dbaf257e512682d530785a6ef77dba2dfdc2f4 /lib | |
parent | 31d3606fe82855dc63cb59fa509577ba1c3a3b86 (diff) | |
download | Nim-3575f2bf9ccdabe5fa1fcade086ef0c11adc67b5.tar.gz |
fix #20972 fixes invalid and UB codegen case object transitions for both refc and ORC [backport] (#21611)
fix #20972 fixes invalid and UB codegen case object transitions for refc and ORC
Diffstat (limited to 'lib')
-rw-r--r-- | lib/system/assign.nim | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/system/assign.nim b/lib/system/assign.nim index 42587929c..9f4cbc0fe 100644 --- a/lib/system/assign.nim +++ b/lib/system/assign.nim @@ -275,10 +275,12 @@ proc genericReset(dest: pointer, mt: PNimType) = proc selectBranch(discVal, L: int, a: ptr array[0x7fff, ptr TNimNode]): ptr TNimNode = - result = a[L] # a[L] contains the ``else`` part (but may be nil) if discVal <% L: - let x = a[discVal] - if x != nil: result = x + result = a[discVal] + if result == nil: + result = a[L] + else: + result = a[L] # a[L] contains the ``else`` part (but may be nil) proc FieldDiscriminantCheck(oldDiscVal, newDiscVal: int, a: ptr array[0x7fff, ptr TNimNode], |