[Issue 4004] DMD 2.042 CTFE regression with functions taking ref parameters

2015-06-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=4004

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|future  |D2

--


[Issue 4004] DMD 2.042 CTFE regression with functions taking ref parameters

2010-04-10 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4004


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4004] DMD 2.042 CTFE regression with functions taking ref parameters

2010-04-01 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4004


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com


--- Comment #2 from Walter Bright bugzi...@digitalmars.com 2010-04-01 
13:53:22 PDT ---
changeset 429

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4004] DMD 2.042 CTFE regression with functions taking ref parameters

2010-03-26 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4004


Don clugd...@yahoo.com.au changed:

   What|Removed |Added

   Keywords||patch
 CC||clugd...@yahoo.com.au


--- Comment #1 from Don clugd...@yahoo.com.au 2010-03-26 12:09:15 PDT ---
Reduced test case for test suite.

void bug4004a(ref int a) {
assert(a==7);
a+=3;
}

void bug4004b(ref int b) {
b= 7;
bug4004a(b);
}

int bug4004c() {
int offset = 5;
bug4004b(offset);
return offset;
}

static assert(bug4004c()==10);
-
PATCH:

Index: interpret.c
===
--- interpret.c(revision 420)
+++ interpret.c(working copy)
@@ -53,7 +53,7 @@
 Expression *interpret_values(InterState *istate, Expression *earg,
FuncDeclaration *fd);

 ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Type *type, Expression
*elem, size_t dim);
-Expression * resolveReferences(Expression *e, Expression *thisval);
+Expression * resolveReferences(Expression *e, Expression *thisval, bool
*isReference = NULL);

 /*
  * Attempt to interpret a function given the arguments.
@@ -1107,8 +1107,11 @@
 // -
 // The variable used in a dotvar, index, or slice expression,
 // after 'out', 'ref', and 'this' have been removed.
-Expression * resolveReferences(Expression *e, Expression *thisval)
+// *isReference will be set to true if a reference was removed.
+Expression * resolveReferences(Expression *e, Expression *thisval, bool
*isReference /*=NULL */)
 {
+if (isReference)
+*isReference = false;
 for(;;)
 {
 if (e-op == TOKthis)
@@ -1131,6 +1134,8 @@
 VarExp *ve2 = (VarExp *)v-value;
 if (!ve2-var-isSymbolDeclaration())
 {
+if (isReference)
+*isReference = true;
 e = v-value;
 continue;
 }
@@ -2087,7 +2092,8 @@
 v-value = e2;
 return e2;
 }
-e1 = resolveReferences(e1, istate-localThis);
+bool destinationIsReference = false;
+e1 = resolveReferences(e1, istate-localThis, destinationIsReference);

 // Unless we have a simple var assignment, we're
 // only modifying part of the variable.
@@ -2167,7 +2174,8 @@
 {
 VarExp *ve = (VarExp *)e1;
 VarDeclaration *v = ve-var-isVarDeclaration();
-addVarToInterstate(istate, v);
+if (!destinationIsReference)
+addVarToInterstate(istate, v);
 v-value = newval;
 }
 else if (e1-op == TOKindex)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---