[Issue 5240] Faster std.random.uniform() for [0.0, 1.0) range

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5240


Denis Derman denis.s...@gmail.com changed:

   What|Removed |Added

 CC||denis.s...@gmail.com


--- Comment #2 from Denis Derman denis.s...@gmail.com 2010-11-21 00:55:34 PST 
---
I would vote for uniform01(). Having it called random() would implicitely
promote to the default random function, from which all other forms of random
would/should be computed.

Denis

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5247] New: std.utf.stride() should not return 0xFF

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5247

   Summary: std.utf.stride() should not return 0xFF
   Product: D
   Version: D2
  Platform: Other
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: rsi...@gmail.com


--- Comment #0 from Shin Fujishiro rsi...@gmail.com 2010-11-21 01:12:18 PST 
---
stride(s, i) returns 0xFF, or 255, if s[i] is not a UTF-8 lead byte. This
design allows the function to silently succeed when the input is broken:

auto str = new char[](300);
str[0] = '\xFE';// broken
str = str[str.stride(0) .. $];  // jumps 255 bytes

stride(s, i) should throw an exception if s[i] is not a lead byte. Or at least
the error value should not be 255.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5247] std.utf.stride() should not return 0xFF

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5247


Jacob Carlborg d...@me.com changed:

   What|Removed |Added

 CC||d...@me.com


--- Comment #1 from Jacob Carlborg d...@me.com 2010-11-21 02:59:58 PST ---
Are you sure that you understand how stride works? stride returns the length of
an UTF sequence, not an index. Why would you try to use the return value of
stride as an index?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5210] PATCH: minor changes to allow compiling with Visual C++ 2008

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5210


simon s.d.hamm...@googlemail.com changed:

   What|Removed |Added

 Attachment #810 is|0   |1
   obsolete||


--- Comment #1 from simon s.d.hamm...@googlemail.com 2010-11-21 04:49:38 PST 
---
Created an attachment (id=826)
PATCH against rev 767, fixes for compiling w/ visual studio

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5179] Make files missing dependency rule for strtold.obj

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5179


simon s.d.hamm...@googlemail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||INVALID


--- Comment #1 from simon s.d.hamm...@googlemail.com 2010-11-21 04:52:29 PST 
---
not actually needed

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5247] std.utf.stride() should not return 0xFF

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5247


nfx...@gmail.com changed:

   What|Removed |Added

 CC||nfx...@gmail.com


--- Comment #2 from nfx...@gmail.com 2010-11-21 05:10:52 PST ---
(In reply to comment #1)
 Are you sure that you understand how stride works? stride returns the length 
 of
 an UTF sequence, not an index. Why would you try to use the return value of
 stride as an index?
You use the length to index into the string or to slice it. Obviously stride()
should return a valid value, and not some undocumented magic (well it's a bug
most likely, and not a feature gone wrong). I don't get what's your problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5240] Faster std.random.uniform() for [0.0, 1.0) range

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5240


st...@despam.it changed:

   What|Removed |Added

 CC||st...@despam.it


--- Comment #3 from st...@despam.it 2010-11-21 05:17:43 PST ---
I am probably missing something, but what is wrong with uniform!(0,1) ?
Then you can add optimizations for all the special cases you want.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


Re: [Issue 2834] Struct Destructors are not called by the GC, but called on explicit delete.

2010-11-21 Thread Sean Kelly
d-bugm...@puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=2834
 
 
 Max Samukha samu...@voliacable.com changed:
 
What|Removed |Added
 
  CC|   
 |samu...@voliacable.com
 
 
 --- Comment #8 from Max Samukha samu...@voliacable.com 2010-11-18
 03:39:17 PST ---
 So what is the verdict? Should we simply specify that struct
 destructors are
 not automatically called except in RAII and remove the struct-in-class
 special
 case?
 
 BTW, there are other problems (serious IMO):
 
 auto ss = new S[10];
 ss.length = 5;
 delete ss; 
 
 Destructors are not called on the last 5 elements.
 
 
 auto ss = new S[10];
 ss ~= ss;
 delete ss;
 
 We have a nasty problem when destructors are called on the appended
 elements
 because postblits was not run for them during append.
 
 etc
 
 Essentially, operations on arrays of structs with postblits/dtors
 defined are
 currently unusable.

I think this is unavoidable. Consider:

auto a = new T[5];
auto b = a[4..5];
a.length = 4;

We can't safely destroy a[4] because it's aliased. Also, since there's
no concept of an owner reference vs an alias, modifying the length of b
could screw up a as well. 

For this and other reasons I'm inclined to withdraw this issue, and
declare that since structs are value types they won't be automatically
destroyed when collected by the GC or when held in arrays.


[Issue 5249] New: Strongly pure random generator

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5249

   Summary: Strongly pure random generator
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-11-21 15:47:51 PST ---
As pure functions become more and more common in D2 programs, I'd like to
generate some random values inside them too. So I suggest to add to the
std.random module a strongly pure function that keeps no state and generates
random values.

This code shows that it's doable (but it's just for demonstration, because this
pseudo random generator is too much weak):


import std.stdio: writeln;

immutable struct rndPair {
double seed, rnd;
}

// strongly pure
// Probably with DMD 2.050 a std.typecons.Tuple can't
// be used as return value here
pure nothrow rndPair nextRandom(const double seed, const double max) {
enum int IA = 3_877, IC = 29_573, IM = 139_968;
immutable double new_seed = (seed * IA + IC) % IM;
return rndPair(new_seed, max * (new_seed * (1.0 / IM)));
}

// strongly pure
pure double[] foo(const int n, const double firstSeed=42) {
double seed = firstSeed;
auto res = new double[n];
foreach (ref r; res) {
auto seed_rnd = nextRandom(seed, 1.0);
r = seed_rnd.rnd;
seed = seed_rnd.seed;
}
return res;
}

void main() {
writeln(foo(5));
// Output:
// [0.37465, 0.729024, 0.636467, 0.793481, 0.538545]
}


If you want two different strongly pure functions may be added, one good enough
generator and one better generator.


Once some unpacking syntax for tuples is present in DMD the foo() may become
more elegant, similar to (this uses what Andrei calls the 'banana syntax', but
other syntaxes are possible):


pure double[] foo(const int n, const double firstSeed=42) {
double seed = firstSeed;
auto res = new double[n];
foreach (ref r; res)
(|r, seed|) = nextRandom(seed, 1.0);
return res;
}


See also bug 5124

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5250] New: Pure std.typecons.Tuple

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5250

   Summary: Pure std.typecons.Tuple
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-11-21 16:12:31 PST ---
This D2 program seems to show that a strongly pure function can't generate and
return a std.typecons.Tuple, but I'd like it, if possible:


import std.typecons: Tuple;
pure Tuple!int foo() {
return Tuple!int(0);
}
void main() {
assert(foo()[0] == 0);
}


dmd 2.050 shows the error:
test.d(3): Error: pure function 'foo' cannot call impure function 'this'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5250] Pure std.typecons.Tuple

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5250



--- Comment #1 from bearophile_h...@eml.cc 2010-11-21 16:21:53 PST ---
The same is true for nothrow attribute:


import std.typecons: Tuple;
pure nothrow Tuple!int foo() {
return Tuple!int(0);
}
void main() {
assert(foo()[0] == 0);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5251] New: Const C file

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5251

   Summary: Const C file
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-11-21 16:31:32 PST ---
I think this program is supposed to work, because fprintf() and fclose() don't
modify 'fout':


import std.c.stdio: fopen, fclose, fprintf;
void main() {
const fout = fopen(test.txt, w);
fprintf(fout, %d, 10); // ERR
fclose(fout); // ERR
}



But DMD 2.050 shows the errors:

test.d(4): Error: function core.stdc.stdio.fprintf (shared(_iobuf)* stream, in
const(char*) format,...) is not callable using argument types
(const(shared(const(_iobuf))*),string,int)
test.d(4): Error: cannot implicitly convert expression (fout) of type
const(shared(const(_iobuf))*) to shared(_iobuf)*
test.d(5): Error: function core.stdc.stdio.fclose (shared(_iobuf)* stream) is
not callable using argument types (const(shared(const(_iobuf))*))
test.d(5): Error: cannot implicitly convert expression (fout) of type
const(shared(const(_iobuf))*) to shared(_iobuf)*

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5252] New: pure nothrow Rebindable

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5252

   Summary: pure nothrow Rebindable
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: rejects-valid
  Severity: enhancement
  Priority: P2
 Component: Phobos
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-11-21 16:39:57 PST ---
This program looks correct:


import std.typecons: Rebindable;
const class Foo {}
pure nothrow void bar() {
Rebindable!Foo f = new Foo;
}
void main() {}


But DMD 2.050 shows the errors:

test.d(4): Error: pure function 'bar' cannot call impure function 'this'
test.d(3): Error: function test3.bar 'bar' is nothrow yet may throw


(I don't know if this is possible in all cases, like when Rebindable is used on
a struct with a nonpure postblit. But with class references I think this is
possible).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5249] Strongly pure random generator

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5249


Jonathan M Davis jmdavisp...@gmx.com changed:

   What|Removed |Added

 CC||jmdavisp...@gmx.com


--- Comment #1 from Jonathan M Davis jmdavisp...@gmx.com 2010-11-21 16:37:52 
PST ---
So, essentially you want a random number generator which is monadic, like you'd
get in a language like Haskell.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5249] Strongly pure random generator

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5249



--- Comment #2 from bearophile_h...@eml.cc 2010-11-21 16:40:59 PST ---
(In reply to comment #1)
 So, essentially you want a random number generator which is monadic, like 
 you'd
 get in a language like Haskell.

Right, but it's not a replacement for the normal random generator, it's one
more function added.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3554] Ddoc generats invalid output for documentation comments with non paired paranthasis

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3554



--- Comment #15 from Witold Baryluk bary...@smp.if.uj.edu.pl 2010-11-21 
16:50:01 PST ---
Thanks for your hard work, but I just tested initial bugreport in DMD 2.050,
and it still do not work as expected.

  /** Produces something in (a;b] */
  float f(float a, float b) { return (a+b)/2.0; }
  /** Produces something in [a;b) */
  float h(float a, float b) { return (a+b)/2.0; }

  void main() { }


brbr
dldtbigfloat uf/u(float ia/i, float ib/i);
/big/dt
ddProduces something in ia/i;ib/i] brbr

/dd
dtbigfloat uh/u(float ia/i, float ib/i);
/big/dt
ddProduces something in [ia/i;ib/i brbr

/dd
/dl


No ( or ).   :(

When compiling with -wi, i got

ttt.d(2): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use
$(LPAREN) instead for unpaired left parentheses.
ttt.d(4): Warning: Ddoc: Stray ')'. This may cause incorrect Ddoc output. Use
$(RPAREN) instead for unpaired right parentheses.

Why it is hard to detect non-macro usage of parantheses? I was thinking macros
need have $ before opening (. 


After creating ddoc file:
RPAREN = )
LPAREN = (

And compiling again, i had now:

brbr
dldtbigfloat uf/u(float ia/i, float ib/i);
/big/dt
ddProduces something in (ia/i;ib/i] brbr

/dd
dtbigfloat uh/u(float ia/i, float ib/i);
/big/dt
ddProduces something in [ia/i;ib/i) brbr

/dd
/dl


Which is exactly what was expected! (Warning are still there). But it works.

So just resolving problem with macro definition in compiler is needed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 2095] covariance w/o typechecks = bugs

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=2095



--- Comment #24 from Stewart Gordon s...@iname.com 2010-11-21 17:26:38 PST ---
(In reply to comment #23)
? extends A[]
 
 Interesting. This type implies array is mutable, so you can put objects into
 it.

No, because you don't know which subclass of A the particular array is of. 
Java does exactly this with its generics - prevents you at compile-time from
putting objects into the data structure for this reason.  All Java generics do
is compile-time type checking - at run-time, a List is a List.  But arrays are
different.

But each element of the array is mutable.

 Java will check at runtime for array type, but in D arrays don't have rtti.

Yes, because Java arrays don't use generics.  Probably for backward
compatibility, since they were invented long before generics were.  They're
just convertible to arrays of any class higher up the hierarchy.  This has been
claimed as one of the main weaknesses of Java's design.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3661] ^^ not supported in array operations.

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3661



--- Comment #9 from Witold Baryluk bary...@smp.if.uj.edu.pl 2010-11-21 
18:04:00 PST ---
  I don't know many methods which use them personally, but it doesn't mean 
  that
  they shouldn't be provided. Actually any formula which have exponent (ie.
  Stirling's approximation) can be used to compute multiple values in 
  parallel,
  so it should be possible to vectorize them easly.
 
 The problem is that they're not going to be efficiently vectorized. It'd be
 possible to have x[] ^^ y[] become arrayPow(x, y); but array pow would just be
 a for-loop of calls to pow().
 I guess what I'm saying is that there'd be no performance benefit.

Now I see. I had no idea that SSE do not have nacassary instructions for this
(log,exp,pow). But this is limitation of hardware vector unit. Language should
not make such limitations. It is possible that new hardware will support more
transcendental functions.

Acutely there are some simple vector libraries, which implements missing
SSE/AVX/AltiVec functions (sin/cos/sincos/exp/log/pow), and can be found in
approximated, precise or strict versions. And even then (with software
emulation) they are faster than just using scalar unit 4 times (and even faster
for AVX with 8 single precision float operands) - just benchmarked some code
from http://gruntthepeon.free.fr/ssemath/ on Intel Core2.

When talking about ^^ operation, it is known that x ^^ y == exp(y * log(x)),
and this is how this operation is implemented most often. Additionally if x is
constant (like few of my examples), log(x) can be precomputed in compile-time.

I'm not only fighting here about performance, but about clear and orthogonal
usage of syntax. It should just work.

Thanks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5253] New: regression, in contracts are not allowed in overriden methods.

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5253

   Summary: regression, in contracts are not allowed in overriden
methods.
   Product: D
   Version: D2
  Platform: x86
OS/Version: Linux
Status: NEW
  Severity: regression
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bary...@smp.if.uj.edu.pl


--- Comment #0 from Witold Baryluk bary...@smp.if.uj.edu.pl 2010-11-21 
18:27:41 PST ---
Minimal test case:

module strange_override_bug;

interface K {
void f();
}

class A(int m) : K {
override void f()
in { }
body { }
}

class B : A!(2) {
void f() { }
}

/*
strange_override_bug.d(8): Error: variable strange_override_bug.A!(2).A.f.this
override cannot be applied to variable
strange_override_bug.d(9): Error: function
strange_override_bug.A!(2).A.f.__require override only applies to class member
functions
*/

Compile with in { } line commented out!
Compiles also if i remove override keyword (and it do not warn my about
anything).

Was working in 2.049.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5253] regression, in contracts are not allowed in overriden methods.

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5253



--- Comment #1 from Witold Baryluk bary...@smp.if.uj.edu.pl 2010-11-21 
18:50:07 PST ---
'int m' parameter in template is also important. Minimizing test case by
removing it, make error disappear. Changing it to general template parameter
(i.e. class A(T) : K) , also makes error disappear.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5254] New: Low performance code with struct constructor

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5254

   Summary: Low performance code with struct constructor
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: performance
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-11-21 18:50:20 PST ---
This D2 test program contains a Foo struct that is a minimized version of a
common 3D vector struct. 

A static if switches between a normal constructor and no constructor with
default initialization of the tree coordiates.


enum bool use_ctor = true;
struct Foo {
static if (use_ctor) {
double x, y, z;

pure nothrow this(double x_, double y_, double z_) {
this.x = x_;
this.y = y_;
this.z = z_;
}
} else {
double x=0.0, y=0.0, z=0.0;
}

Foo muls(double s) {
return Foo(this.x*s, this.y*s, this.z*s);
}
}
void main() {}



I have compiled the two versions using DMD 2.050 with dmd -O -release -inline

The resulting asm shows a significant difference. The full program that uses
the 3D vectors too shows a different performance in the cases:

---

use_ctor=true:

_D4test3Foo6__ctorMFNaNbNcdddZS4test3Foocomdat
assume  CS:_D4test3Foo6__ctorMFNaNbNcdddZS4test3Foo
mov ECX,EAX
fld qword ptr 014h[ESP]
fld qword ptr 0Ch[ESP]
fld qword ptr 4[ESP]
fxchST2
fstpqword ptr [ECX]
fstpqword ptr 8[ECX]
fstpqword ptr 010h[ECX]
ret 018h
_D4test3Foo6__ctorMFNaNbNcdddZS4test3Fooends
_D4test3Foo4mulsMFdZS4test3Foo  comdat
assume  CS:_D4test3Foo4mulsMFdZS4test3Foo
sub ESP,028h
mov ECX,EAX
pushESI
mov ESI,offset FLAT:_D4test3Foo6__initZ
pushEDI
lea EDI,8[ESP]
movsd
movsd
movsd
movsd
movsd
movsd
fld qword ptr 8[ECX]
fld qword ptr 010h[ECX]
fxchST1
fmulqword ptr 038h[ESP]
lea ESI,8[ESP]
mov EDI,034h[ESP]
fxchST1
fmulqword ptr 038h[ESP]
fld qword ptr [ECX]
fmulqword ptr 038h[ESP]
fxchST2
fstpqword ptr 020h[ESP]
fxchST1
fld qword ptr 020h[ESP]
fxchST2
fstpqword ptr 028h[ESP]
fxchST1
fld qword ptr 028h[ESP]
fxchST2
fstpqword ptr 8[ESP]
fstpqword ptr 010h[ESP]
fstpqword ptr 018h[ESP]
movsd
movsd
movsd
movsd
movsd
movsd
mov EAX,034h[ESP]
pop EDI
pop ESI
add ESP,028h
ret 0Ch
_D4test3Foo4mulsMFdZS4test3Foo  ends

---

use_ctor=false:

_D4test3Foo4mulsMFdZS4test3Foo  comdat
assume  CS:_D4test3Foo4mulsMFdZS4test3Foo
mov ECX,EAX
mov EDX,4[ESP]
mov EAX,EDX
fld qword ptr [ECX]
fmulqword ptr 8[ESP]
fstpqword ptr [EDX]
fld qword ptr 8[ECX]
fmulqword ptr 8[ESP]
fstpqword ptr 8[EDX]
fld qword ptr 010h[ECX]
fmulqword ptr 8[ESP]
fstpqword ptr 010h[EDX]
ret 0Ch
_D4test3Foo4mulsMFdZS4test3Foo  ends

---

Using LDC1:

_D7path13e2V34mulsMFdZS7path13e2V3:
movsd   8(%esp), %xmm0
movapd  %xmm0, %xmm1
mulsd   16(%eax), %xmm1
movapd  %xmm0, %xmm2
mulsd   8(%eax), %xmm2
mulsd   (%eax), %xmm0
movl4(%esp), %eax
movsd   %xmm0, (%eax)
movsd   %xmm2, 8(%eax)
movsd   %xmm1, 16(%eax)
ret $12

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5256] New: null Rebindable testing not supported

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5256

   Summary: null Rebindable testing not supported
   Product: D
   Version: D2
  Platform: x86
OS/Version: Windows
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-11-21 18:55:50 PST ---
This D2 program shows that you can't test if a class reference wrapped with
Rebindable is null:


import std.typecons;
const class Foo {}
void main() {
auto a = Rebindable!Foo(new Foo);
a = new Foo;
assert(a !is null); // err
}


DMD 2.050 generates:
test.d(6): Error: incompatible types for ((a) !is (null)):
'Rebindable!(const(Foo))' and 'void*'


Is this the currently correct way to do it? (It works):

assert(a.get() !is null); // OK

I have seen the get() method is not documented on the site, so is that a
temporary limitation caused by the unfinished alis this implementation?

(Issue tagged with Component: DMD because I think it's a limit of alias
this).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5056] Warning against virtual method call from constructor

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5056


Witold Baryluk bary...@smp.if.uj.edu.pl changed:

   What|Removed |Added

 CC||bary...@smp.if.uj.edu.pl


--- Comment #10 from Witold Baryluk bary...@smp.if.uj.edu.pl 2010-11-21 
19:07:23 PST ---
  This confuses me. It works both in D1 and D2. Maybe it's a regression?
  The spec says:
  
  3. It is illegal to refer to this implicitly or explicitly prior to making 
  a
  constructor call.
  http://www.digitalmars.com/d/1.0/class.html#constructors
 
 I interpret that the same way you do.   I think maybe that this is a rule that
 was removed, but someone forgot to remove it from the docs?  I think you 
 should
 file a separate doc bug on it.
 
 It doesn't strike me as a good requirement anyways.  What problems does having
 that restriction prevent?

Hmm. I was using this feature, setting fields before calling super(), for
VERY long time. It worked, so i never actually payed attention, if i call
super() at the beginning or the end of constructor - both worked well.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5249] Strongly pure random generator

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5249



--- Comment #3 from bearophile_h...@eml.cc 2010-11-21 20:03:55 PST ---
A bit more realistic (but not complete, not commented, etc) test using one of
the rnd generator of the std.random module:


pure nothrow UIntType pureLinearCongruential(UIntType, UIntType a, UIntType c,
UIntType m)
(UIntType x0) {
// perform compile-time tests on a, c, m here...

static if (m) {
UIntType _x = x0 % m; // slow?

static if (is(UIntType == uint)  m == uint.max) {
immutable ulong x = (cast(ulong) a * _x + c);
immutable ulong v = x  32;
immutable ulong w = x  uint.max;
immutable y = cast(uint)(v + w);
_x = (y  v || y == uint.max) ? (y + 1) : y;
} else static if (is(UIntType == uint)  m == int.max) {
immutable ulong x = (cast(ulong) a * _x + c);
immutable ulong v = x  31;
immutable ulong w = x  int.max;
immutable uint y = cast(uint)(v + w);
_x = (y = int.max) ? (y - int.max) : y;
} else {
_x = cast(UIntType) ((cast(ulong) a * _x + c) % m);
}
} else {
UIntType _x = a * _x0 + c;
}

return _x;
}

alias pureLinearCongruential!(uint, 16807, 0, 2147483647) pureMinstdRand0;

import std.stdio: writeln;

void main() {
uint rnd = 10;
foreach (_; 0 .. 10) {
rnd = pureMinstdRand0(rnd);
writeln(rnd);
}
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 5161] Selective import results in conflicting definition.

2010-11-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=5161


Witold Baryluk bary...@smp.if.uj.edu.pl changed:

   What|Removed |Added

 CC||bary...@smp.if.uj.edu.pl


--- Comment #1 from Witold Baryluk bary...@smp.if.uj.edu.pl 2010-11-21 
22:04:43 PST ---
I had the same problem in D2.049. I think it is regression, as it was working
previously without problem.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---