[Issue 17487] New: CTFE should allow casting delegate function attributes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jun 9 13:07:27 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17487
Issue ID: 17487
Summary: CTFE should allow casting delegate function attributes
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: eyal at weka.io
import std.traits;
struct S {
int f() { return 1; }
int delegate() @nogc fAsNoGc() {
alias F = typeof(&f);
enum oldAttrs = functionAttributes!F;
return cast(SetFunctionAttributes!(F, functionLinkage!F, oldAttrs |
FunctionAttribute.nogc))&f;
}
}
int moo() { return S().fAsNoGc()(); }
auto x = moo(); // CTFE, fails
void main() {
auto y = moo(); // runtime, succeeds
}
--
More information about the Digitalmars-d-bugs
mailing list