digitalmars.D.bugs - [Issue 3671] New: x^^3 gives wrong result when x is a floating-point literal
- d-bugmail puremagic.com (19/19) Jan 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3671
- d-bugmail puremagic.com (41/41) Jan 04 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3671
- d-bugmail puremagic.com (10/10) Jan 11 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3671
- d-bugmail puremagic.com (11/11) Jan 30 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3671
http://d.puremagic.com/issues/show_bug.cgi?id=3671
Summary: x^^3 gives wrong result when x is a floating-point
literal
Product: D
Version: 2.038
Platform: Other
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: bugzilla kyllingen.net
03:30:57 PST ---
x^^3 evaluates to x^^2 when x is a floating-point literal.
writeln(2.0^^3); // prints 4
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3671
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug yahoo.com.au
Severity|major |critical
Ouch. I don't know what's happened here. The test suite I provided with the
patch in bug 3577 doesn't compile!
This quick patch fixes the immediate bug reported here, but it still doesn't
compile the 3577 test suite.
The culprit is the call to typeCombine(). The test needs to be performed before
that.
Index: expression.c
===================================================================
--- expression.c (revision 324)
+++ expression.c (working copy)
-9965,6 +9971,9
) && (e1->op == TOKint64 || e1->op == TOKfloat64)
)
{
+ bool wantCube = (e2->op == TOKint64 && e2->toInteger() == 3)
+ || (e2->op == TOKfloat64 && e2->toReal() == 3.0);
+
typeCombine(sc);
// Replace x^^2 with (tmp = x, tmp*tmp)
// Replace x^^3 with (tmp = x, tmp*tmp*tmp)
-9973,8 +9982,8
VarExp * ve = new VarExp(loc, tmp);
Expression *ae = new DeclarationExp(loc, tmp);
Expression *me = new MulExp(loc, ve, ve);
- if ( (e2->op == TOKint64 && e2->toInteger() == 3)
- || (e2->op == TOKfloat64 && e2->toReal() == 3.0))
+
+ if ( wantCube)
me = new MulExp(loc, me, ve);
e = new CommaExp(loc, ae, me);
e = e->semantic(sc);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 04 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3671
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla digitalmars.com
22:01:23 PST ---
Changeset 332
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 11 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3671
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
22:46:39 PST ---
fixed dmd 2.040
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 30 2010









d-bugmail puremagic.com 