-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.byref
always optimizes sink call into a bitwise memcopy if =sink
is disabled
#24327
base: devel
Are you sure you want to change the base?
Conversation
compiler/injectdestructors.nim
Outdated
@@ -277,7 +277,8 @@ proc deepAliases(dest, ri: PNode): bool = | |||
proc genSink(c: var Con; s: var Scope; dest, ri: PNode; flags: set[MoveOrCopyFlag] = {}): PNode = | |||
if (c.inLoopCond == 0 and (isUnpackedTuple(dest) or IsDecl in flags or | |||
(isAnalysableFieldAccess(dest, c.owner) and isFirstWrite(dest, c)))) or | |||
isNoInit(dest) or IsReturn in flags: | |||
isNoInit(dest) or IsReturn in flags or | |||
tfByRef in dest.typ.flags: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the logic should be "it's .byref and also has its =sink disabled".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense
.byref
always optimizes sink call into a bitwise memcopy.byref
always optimizes sink call into a bitwise memcopy if =sink
is disabled
This is still not correct as it can introduce leaks for code like |
I usually use |
I think so, yes, but making =sink an .error just because you want to tie the object to a stack location is wrong regardless. |
closes #75
ref nim-lang/threading#79
Or only when
=sink
is disabled forbyRef