Skip to content

Commit

Permalink
defines the gcRefc symbol which allows writing specific code for re…
Browse files Browse the repository at this point in the history
…fc (#20009)

* define gcRefc symbols

* add comments

* add a changelog item

* Update changelog.md

Co-authored-by: konsumlamm <[email protected]>

* Update changelog.md

Co-authored-by: Yardanico <[email protected]>

Co-authored-by: konsumlamm <[email protected]>
Co-authored-by: Yardanico <[email protected]>
  • Loading branch information
3 people authored Jul 17, 2022
1 parent 0d8bec6 commit 01ad0cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ becomes an alias for `addr`.
In the command line, this is defined as `-d:a.b.c`. Older versions can
use accents as in ``defined(`a.b.c`)`` to access such defines.

- Defines the `gcRefc` symbol which allows writing specific code for the refc GC.

## Compiler changes

- `nim` can now compile version 1.4.0 as follows: `nim c --lib:lib --stylecheck:off compiler/nim`,
Expand Down
1 change: 1 addition & 0 deletions compiler/commands.nim
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ proc processMemoryManagementOption(switch, arg: string, pass: TCmdLinePass,
incl conf.globalOptions, optTlsEmulation # Boehm GC doesn't scan the real TLS
of "refc":
unregisterArcOrc(conf)
defineSymbol(conf.symbols, "gcrefc")
conf.selectedGC = gcRefc
of "markandsweep":
unregisterArcOrc(conf)
Expand Down
7 changes: 6 additions & 1 deletion tests/stdlib/tstrutils2.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
discard """
matrix: "--gc:refc; --gc:orc"
"""

import "$lib/.." / compiler/strutils2

block: # setLen
var a = "abc"
a.setLen 0
a.setLen 3, isInit = false
doAssert a[1] == 'b'
when defined(gcRefc): # bug #19763
doAssert a[1] == 'b'
a.setLen 0
a.setLen 3, isInit = true
doAssert a[1] == '\0'
Expand Down

0 comments on commit 01ad0cd

Please sign in to comment.