2.058 broke my build. Is this a bug?
Dmitry Olshansky
dmitry.olsh at gmail.com
Fri Feb 24 01:05:41 PST 2012
On 24.02.2012 10:28, Caligo wrote:
> ----------------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];
I guess that should be
foreach(i; 0..r)
foreach(j; 0..c)
t += this[i,j];
since you do row/col multiplication in opIndex?
> 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
--
Dmitry Olshansky
More information about the Digitalmars-d-learn
mailing list