[Issue 13850] New: mixin template accepts delegates as function parameters
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Dec 10 02:39:24 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13850
Issue ID: 13850
Summary: mixin template accepts delegates as function
parameters
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: accepts-invalid
Severity: major
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: schuetzm at gmx.net
Reported by Vlasov Roman:
http://forum.dlang.org/thread/outsrxhcechsbkniudtz@forum.dlang.org
import std.stdio;
mixin template Template(void function() func1, void function()
func2) {
void to() {
func1();
func2();
}
};
class SomeClass {
mixin Template!(&func, &func23);
void func() {
writeln("First function!");
}
void func23() {
writeln("First function!");
}
void toTemplate() {
to();
}
}
void main() {
SomeClass a = new SomeClass();
a.toTemplate();
}
This compiles, but segfaults at runtime, because the delegates &func and
&func23 are evidently passed to Template as function pointers.
--
More information about the Digitalmars-d-bugs
mailing list