Files
Nim/compiler
ringabout 26a4b137c6 [backport] fixes #23690; SIGSEGV with object variants and RTTI (#23703)
fixes #23690

```nim
dest.`:state` = src.`:state`
var :tmp_553651276 = dest.e1.a
`=wasMoved`(dest.e1.a)
dest.e1.a.kind = src.e1.a.kind
case dest.e1.a.kind
of 0:
  dest.e1.a.a = src.e1.a.a
of 1:
  `=copy`(dest.e1.a.c, src.e1.a.c)
case :tmp_553651276.kind
of 0:
of 1:
  `=destroy`(:tmp_553651276.c)
```
`dest.e1.a.kind = src.e1.a.kind` changes the discrimant but it fails to
clear the memory of `dest.e1.a`. Before using hooks for copying, we need
to clear the dest, e.g. `=wasMoved(dest.e1.a.c)`.

```nim
dest.`:state` = src.`:state`
var :tmp_553651276 = dest.e1.a
`=wasMoved`(dest.e1.a)
dest.e1.a.kind = src.e1.a.kind
case dest.e1.a.kind
of 0:
  `=wasMoved`(dest.e1.a.a)
  dest.e1.a.a = src.e1.a.a
  `=wasMoved`(dest.e1.a.b)
of 1:
  `=wasMoved`(dest.e1.a.c)
  `=copy`(dest.e1.a.c, src.e1.a.c)
case :tmp_553651276.kind
of 0:
of 1:
  `=destroy`(:tmp_553651276.c)
```

(cherry picked from commit 262ff648aa)
2024-06-11 14:04:29 +02:00
..
2022-12-26 13:20:05 +01:00
2022-09-27 10:57:47 +02:00
2022-09-27 10:57:47 +02:00
2024-06-07 15:34:34 +02:00
2024-05-21 14:52:29 +02:00
2024-05-21 14:52:29 +02:00
2017-01-07 22:35:09 +01:00
2023-06-27 22:42:48 +02:00
2022-12-16 08:01:15 +01:00
2019-11-28 17:13:04 +01:00
2024-05-23 13:55:23 +02:00
2023-05-06 21:27:28 +02:00
2023-05-11 10:10:51 +02:00
2023-05-06 19:10:13 +02:00
2021-01-12 09:36:51 +01:00
2022-03-23 20:34:53 +01:00
2022-10-01 16:46:51 +02:00
2022-10-17 23:48:51 +02:00
2023-07-02 22:36:05 +02:00
2023-01-01 10:25:04 +01:00
2024-05-21 14:52:29 +02:00
2023-06-17 05:42:05 +02:00
2023-06-17 05:42:05 +02:00

Nim Compiler

  • This directory contains the Nim compiler written in Nim.
  • Note that this code has been translated from a bootstrapping version written in Pascal.
  • So the code is not a poster child of good Nim code.

See Internals of the Nim Compiler for more information.