2.058 broke my build. Is this a bug?

James Miller james at aatch.net
Fri Feb 24 18:44:49 PST 2012


On Feb 25, 2012 12:16 PM, "Caligo" <iteronvexor at gmail.com> wrote:
>
> That was a typo, and it doesn't change anything.  Here is a shorter
version:
>
> ----------------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----------------
>
>
>
> And here is the error:
>
> /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

Hmm it seems that the delegate is being implicitly marked as system, and im
not sure why benchmark is @safe. I'd say file a bug report.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120225/3f195cbe/attachment.html>


More information about the Digitalmars-d-learn mailing list