https://issues.dlang.org/show_bug.cgi?id=23416
Issue ID: 23416
Summary: Difference DMD/GDC: Error: non-constant expression `&
foo`
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
```
module dmd_gdc_difference;
template funcptr (alias method) {
immutable funcptr = &method;
}
struct S {
void function () fun;
void foo ()
{
fun = funcptr!foo;
}
}
unittest {
S m;
}
```
$ dmd -unittest -main dmd-gdc-difference.d
dmd-gdc-difference.d(4): Error: non-constant expression `& foo`
$ gdc -funittest -fmain dmd-gdc-difference.d -o dmd-gdc-difference
$ ./dmd-gdc-difference
1 modules passed unittests
Versions checked: GDC 12.1, 11.3; DMD v2.100.2, 2.080.0
Found in: https://forum.dlang.org/post/[email protected]
(Generate a pointer to a method of a struct)
--