[Issue 23112] code passes @nogc, allocates anyway

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 5 19:19:48 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23112

--- Comment #6 from Walter Bright <bugzilla at digitalmars.com> ---
Regarding `f` as escaping produces far too many false positives.

1. semantic3 (the function body) analysis is done for a function. No gc use is
found, and no escapes of an aliased reference are found, so the function is
inferred @nogc. This also enables some NRVO optimizations.

2. code is generated that depends on the @nogc inferred attribute of the
function, and/or does NRVO.

3. code is generated via another template getting expanded that escapes the
alias reference.

4. this gets detected by the code the decides whether to generate a closure or
not, and now (2) is invalid, but it's too late.

--


More information about the Digitalmars-d-bugs mailing list