[Issue 24762] New: @nogc false positive error
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Sep 11 12:16:52 UTC 2024
    
    
  
https://issues.dlang.org/show_bug.cgi?id=24762
          Issue ID: 24762
           Summary: @nogc false positive error
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eyal at weka.io
struct S { int m; }
  string m() { return "m"; }
  @nogc void f() {
      S s;
      auto x = __traits(getMember, s, m()); // Error: `@nogc` function `nogc.f`
cannot call non- at nogc function `nogc.m`
  }
Of course, this can be worked around with:
    enum M = m();
    auto x = __traits(getMember, s, M);
But the m() call is in compile-time, and should not relate to the runtime @nogc
enforcement inside f().
--
    
    
More information about the Digitalmars-d-bugs
mailing list