Bug 24762 – @nogc false positive error

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-09-11T12:16:52Z
Last change time
2024-09-12T11:45:43Z
Keywords
pull
Assigned to
No Owner
Creator
Eyal

Comments

Comment #0 by eyal — 2024-09-11T12:16:52Z
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-@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().
Comment #1 by dlang-bot — 2024-09-11T14:16:56Z
@RazvanN7 created dlang/dmd pull request #16835 "Fix Bugzilla Issue 24762 - @nogc false positive error" fixing this issue: - Fix Bugzilla Issue 24762 - @nogc false positive error https://github.com/dlang/dmd/pull/16835
Comment #2 by dlang-bot — 2024-09-12T11:45:43Z
dlang/dmd pull request #16835 "Fix Bugzilla Issue 24762 - @nogc false positive error" was merged into master: - d270e2e018a2973e627533eef498e841105fcd2f by RazvanN7: Fix Bugzilla Issue 24762 - @nogc false positive error https://github.com/dlang/dmd/pull/16835