[Issue 23416] New: Difference DMD/GDC: Error: non-constant expression `& foo`
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 15 00:18:02 UTC 2022
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: nobody at puremagic.com
Reporter: kdevel at vogtner.de
```
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/lnjjxiuzuqdjhaeiizhf@forum.dlang.org
(Generate a pointer to a method of a struct)
--
More information about the Digitalmars-d-bugs
mailing list