digitalmars.D.bugs - [Issue 7774] New: I've found a bug in D2
- d-bugmail puremagic.com (65/65) Mar 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7774
- d-bugmail puremagic.com (13/13) Mar 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7774
- d-bugmail puremagic.com (13/14) Mar 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7774
- d-bugmail puremagic.com (23/23) Mar 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7774
- d-bugmail puremagic.com (7/22) Mar 25 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7774
- d-bugmail puremagic.com (8/10) Mar 26 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7774
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 puremagic.com ReportedBy: vangelisforever yandex.ru --- Comment #0 from Andrey Derzhavin <vangelisforever 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: -------
Mar 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7774 Dmitry Olshansky <dmitry.olsh gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dmitry.olsh gmail.com --- Comment #1 from Dmitry Olshansky <dmitry.olsh gmail.com> 2012-03-25 12:59:59 PDT --- I'm using your exact code, it works fine here on dmd2.059head win7 and prints 2 2 Your version of dmd, system spec? PS: I totally expected thouse ifs to be static ifs. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7774 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc --- Comment #2 from bearophile_hugs eml.cc 2012-03-25 13:06:05 PDT --- If confirmed this bug report needs a better name :-) (In reply to comment #1)PS: I totally expected thouse ifs to be static ifs.Those variables are known at compile-time, so a good compiler is supposed to remove the useless if branches (quite probably dmd does it). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7774 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |timon.gehr gmx.ch Resolution| |WORKSFORME --- Comment #3 from timon.gehr gmx.ch 2012-03-25 13:48:49 PDT --- You have found a bug in DMD 2.058, not in D2. Smaller test case: struct A{ double x; void f(double d){x%=cast(double)d;} } void main(){ auto a=A(10); a.f(8); assert(a.x!=10.0); } Works with DMD 2.059head, fails with DMD 2.058. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7774 --- Comment #4 from Andrey Derzhavin <vangelisforever yandex.ru> 2012-03-25 23:46:44 PDT --- (In reply to comment #3)You have found a bug in DMD 2.058, not in D2. Smaller test case: struct A{ double x; void f(double d){x%=cast(double)d;} } void main(){ auto a=A(10); a.f(8); assert(a.x!=10.0); } Works with DMD 2.059head, fails with DMD 2.058.How can I get a DMD 2.059 linux version or DMD 2.0? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 25 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7774 --- Comment #5 from timon.gehr gmx.ch 2012-03-26 00:04:47 PDT --- (In reply to comment #4)How can I get a DMD 2.059 linux version or DMD 2.0?It hasn't been released yet, but you can build it from source: https://github.com/D-Programming-Language/dmd -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 26 2012