Is this a operator overloading bug?

mike vertex at gmx.at
Thu Jan 11 06:45:00 PST 2007


Am 11.01.2007, 15:31 Uhr, schrieb Oskar Linde  
<oskar.lindeREM at OVEgmail.com>:

> It creates a new default-initialized Vector3, *initializes* it and  
> returns it. I don't see anything wrong with the code. The result of the  
> original code should be "222", not "nannannan".

Yes, but the default initializer for float is NaN, so:

' Vector3 opMul(float s)
' {
'  Vector3 ret; // <-- creates new, and
'  ret.x = x*s; // <-- oh, wait a sec ... this x should be initialized
'  ret.y = y*s;
'  ret.z = z*s;
'  return ret;
' }
'}

Now I'm confused ... :)
Maybe it's really a bug.

-mike

-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list