Thread overview | |||||
---|---|---|---|---|---|
|
February 25, 2012 [Issue 7577] New: Delegate implicitly marked as system | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7577 Summary: Delegate implicitly marked as system Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: iteronvexor@gmail.com --- Comment #0 from iteronvexor@gmail.com 2012-02-24 19:22:24 PST --- ----------------8<----------------8<---------------- import std.datetime; import std.stdio; struct A{ auto fun(A a){ return 0; } } void bench(alias fun)(string msg, uint n = 1_000_000){ auto b = benchmark!fun(n); writefln(" %s %s ms", msg, b[0].to!("msecs", int)); } unittest{ A a, b; void test1(){ auto r = a.fun(b); } bench!( {auto r = a.fun(b);} )("Does Not work"); bench!(test1)("Works"); } void main(){ } ---------------->8---------------->8---------------- DMD 2.058, GNU/Linux 64-bit /usr/include/d/dmd/phobos/std/datetime.d(30986): Error: safe function 'benchmark' cannot call system delegate '__lambda1' t1.d(11): Error: template instance t1.__unittest2.benchmark!(__lambda1) error instantiating t1.d(23): instantiated from here: bench!(delegate @system void() { int r = a.fun(b); } ) t1.d(23): Error: template instance t1.__unittest2.bench!(delegate @system void() { int r = a.fun(b); } ) error instantiating -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 26, 2012 [Issue 7577] Delegate implicitly marked as system | ||||
---|---|---|---|---|
| ||||
Posted in reply to iteronvexor@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=7577 --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-02-25 21:24:01 PST --- (In reply to comment #0) > ----------------8<----------------8<---------------- > import std.datetime; > import std.stdio; > > struct A{ > > auto fun(A a){ return 0; } > } > > void bench(alias fun)(string msg, uint n = 1_000_000){ > > auto b = benchmark!fun(n); > writefln(" %s %s ms", msg, b[0].to!("msecs", int)); > } > > unittest{ > > A a, b; > > void test1(){ > auto r = a.fun(b); > } > > bench!( {auto r = a.fun(b);} )("Does Not work"); > bench!(test1)("Works"); > } > > void main(){ } > ---------------->8---------------->8---------------- > > DMD 2.058, GNU/Linux 64-bit > > /usr/include/d/dmd/phobos/std/datetime.d(30986): Error: safe function > 'benchmark' cannot call system delegate '__lambda1' > t1.d(11): Error: template instance > t1.__unittest2.benchmark!(__lambda1) error instantiating > t1.d(23): instantiated from here: bench!(delegate @system void() > { > int r = a.fun(b); > } > ) > t1.d(23): Error: template instance t1.__unittest2.bench!(delegate @system > void() > { > int r = a.fun(b); > } > ) error instantiating A.fun is not marked as @safe, so {auto r = a.fun(b);} inferred as @system. Then delegate inference has no problem. Additionally, std.datetime.benchmark requires that its arguments fun are @safe. I don't know why that. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 19, 2013 [Issue 7577] Delegate implicitly marked as system | ||||
---|---|---|---|---|
| ||||
Posted in reply to iteronvexor@gmail.com | http://d.puremagic.com/issues/show_bug.cgi?id=7577 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WORKSFORME --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2013-02-19 00:42:10 PST --- (In reply to comment #1) > A.fun is not marked as @safe, so {auto r = a.fun(b);} inferred as @system. Then delegate inference has no problem. > > Additionally, std.datetime.benchmark requires that its arguments fun are @safe. I don't know why that. Hmm, my comment was not correct, and probably a compiler bug had been there. But, it works with 2.062. Compiler bug seems already be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation