2.058 broke my build. Is this a bug?

Caligo iteronvexor at gmail.com
Thu Feb 23 22:28:58 PST 2012


----------------8<----------------8<----------------

import std.datetime : benchmark;
import std.stdio : writefln;

struct A(int r, int c){

 public:
  alias float[r * c] Data;

  Data _data;

  auto opBinary(A a){
    float t;
    foreach(i; 0..r*c)
      foreach(j; 0..r*c)
	t += this[i,j];
    return a;
  }
  pure float opIndex(size_t rr, size_t cc = 0) const{ return _data[cc
+ rr * c]; }

  pure ref float opIndex(size_t rr, size_t cc = 0){ return _data[cc + rr * c]; }
}

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{

  alias A!(3, 3) AA;
  AA a;

  bench!( {auto r = a * a;})("broken");
}

void main(){ }

---------------->8---------------->8----------------

Other parts of my code using bench() works fine, except in rare cases.
 So I'm guessing this is a bug?  I can't tell if it's in DMD or
std.datetime.  Can anyone help?

I will bug report myself tomorrow if it turns out to be a bug for sure.

DMD 2.058, 64-bit GNU/Linux


More information about the Digitalmars-d-learn mailing list