[Issue 19679] variable escapes unnoticed when referenced in function called from function whose address is taken
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 16 07:57:13 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19679
Iain Buclaw <ibuclaw at gdcproject.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ibuclaw at gdcproject.org
--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject.org> ---
I think the correct place to check would be checkEscapingSiblings.
// After g.isThis() check.
for (auto p = g; p; p = p.parent.isFuncDeclaration())
{
// A parent of the sibling had its address taken.
// Assume escaping of parent affects its children, so needs propagating.
if (p.tookAddressOf)
{
markAsNeedingClosure(p, outerFunc);
bAnyClosures = true;
}
}
It's a bit of a weak check though. It would be a stronger guarantee to keep a
reference of _all_ callers of a function, not just its siblings, so that nested
functions that are unreferenced are correctly ignored.
--
More information about the Digitalmars-d-bugs
mailing list