[Issue 829] New: struct operator opMul() return a wrong value

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 11 00:37:40 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=829

           Summary: struct operator opMul() return a wrong value
           Product: D
           Version: 1.00
          Platform: PC
               URL: http://www.digitalmars.com/pnews/read.php?server=news.di
                    gitalmars.com&group=digitalmars.D&artnum=46576
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: timfang2006 at 126.com


The code below output is "nannannan".The code works properly in DMD 0.177 but 
fails in DMD 0.178 and 1.00.

--code---------------------
import std.stdio;

void main()
{
 Vector3 a;
 a.set(1,1,1);
 a = a*2;
 writefln(a.x, a.y, a.z);
}


struct Vector3
{
 float x,y,z;

 // constructor
 void set(float _x, float _y, float _z)
 {
  x = _x;
  y = _y;
  z = _z;
 }

 Vector3 opMul(float s)
 {
  Vector3 ret;
  ret.x = x*s;
  ret.y = y*s;
  ret.z = z*s;
  return ret;
 }
}


-- 



More information about the Digitalmars-d-bugs mailing list