[Issue 7774] New: I've found a bug in D2
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 25 12:33:01 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7774
Summary: I've found a bug in D2
Product: D
Version: D2
Platform: x86
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: vangelisforever at yandex.ru
--- Comment #0 from Andrey Derzhavin <vangelisforever at yandex.ru> 2012-03-25 12:33:25 PDT ---
Try next code:
import std.stdio;
template TX(T)
{
struct A
{
T x;
T y;
public void opOpAssign(string op)(double d)
{
debug writeln(op);
if (op == "+")// +=
{
x += cast(T)d;
y += cast(T)d;
} else
if (op == "-") // -=
{
x -= cast(T)d;
y -= cast(T)d;
} else
if (op == "*") // *=
{
x *= cast(T)d;
y *= cast(T)d;
} else
if (op == "/") // /=
{
x /= cast(T)d;
y /= cast(T)d;
} else
if (op == "%") // %=
{
x %= cast(T)d;
y %= cast(T)d;
}
}
}
}
void main(string[] args)
{
TX!(double).A a;
a.x =10;
a.y = 10;
a%=8.0;
writeln(a.x, " ", a.y);
}
You'll see that the a.x won't change. It must be 2 after %= operation.
Thank you.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list