DMD 1.001 release is broken
Walter Bright
newshound at digitalmars.com
Fri Jan 26 00:14:27 PST 2007
Lionello Lunesu wrote:
> Walter Bright wrote:
>> I believe this fails with C++, too. But I don't think there's any
>> solution to it but completely disable NRVO. There's no reasonable way
>> for the compiler to detect that the d's are aliased. But NRVO is too
>> valuable an optimization. So instead I'll argue that this is akin to:
>> i = i++;
>> i.e. it's an order-of-evaluation issue that should be avoided.
>
> This still fails:
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=46576
>
>
> (it's also in bugzilla, issue 829)
>
> There's no "inout", just:
>
> struct Vector3 {
> //....
> Vector3 opMul(float s)
> {
> Vector3 ret;
> ret.x = x*s;
> ret.y = y*s;
> ret.z = z*s;
> return ret;
> }
> }
>
> Vector3 a;
> a.set(1,1,1);
> a = a*2;
> // a will be nan,nan,nan
>
> Where did those nans come from? Must be the initializers from the return
> value "ret".
Declaring ret as:
Vector3 ret = void;
will cure the problem. But I agree it's a problem, because it looks like
it should work.
More information about the Digitalmars-d-announce
mailing list