D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19285 - false positive GC inferred
Summary: false positive GC inferred
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 major
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2018-10-02 21:31 UTC by Eyal
Modified: 2022-06-09 04:12 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Eyal 2018-10-02 21:31:49 UTC
No GC is actually used here:

void f(bool cond, string s) @nogc {
    auto inner() { return s; }
    alias Unused1 = typeof(inner); // OK
    alias Unused2 = typeof(&inner); // INFERS GC
}

This is especially interesting when trying to use functionAttribute!inner and others that internally "take address" (not really) of the given function and wrongly infer GC is needed.
Comment 1 Dlang Bot 2022-06-08 23:33:53 UTC
@maxhaton created dlang/dmd pull request #14195 "Fix Issue 19285 - False GC positive caused by AddressOf inside typeof…" fixing this issue:

- Fix Issue 19285 - False GC positive caused by AddressOf inside typeof polluting global semantic state.

https://github.com/dlang/dmd/pull/14195
Comment 2 Dlang Bot 2022-06-09 04:12:51 UTC
dlang/dmd pull request #14195 "Fix Issue 19285 - False GC positive caused by AddressOf inside typeof…" was merged into master:

- b06afb8bfebbb31d675171c7e7840bf0d40155e0 by mhh:
  Fix Issue 19285 - False GC positive caused by AddressOf inside typeof polluting global semantic state.
  
  This patch also adds a new method isFromSpeculativeSemanticContext
  to the Scope struct to avoid repition of this logic in the compiler.

https://github.com/dlang/dmd/pull/14195