[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

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

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

   What|Removed |Added

Version|2.036   |D2

--


[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

2010-06-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3569


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

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution||FIXED


--- Comment #7 from Walter Bright bugzi...@digitalmars.com 2010-06-27 
20:50:24 PDT ---
http://www.dsource.org/projects/dmd/changeset/563

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


[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

2010-06-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3569


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

   What|Removed |Added

   Keywords|rejects-valid   |ice-on-valid-code


--- Comment #5 from Don clugd...@yahoo.com.au 2010-06-07 06:59:26 PDT ---
This is causing a stack overflow again. I don't know why I thought it was
fixed.

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


[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

2010-06-07 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3569


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

   What|Removed |Added

   Keywords||patch


--- Comment #6 from Don clugd...@yahoo.com.au 2010-06-07 13:24:35 PDT ---
The fact that struct initializers are evaluated at compile time is bug 3809;
only the stack overflow is unique to this bug.

Some tough cases for the test suite.
---
template Compileable(int z) { bool OK;}

struct Bug3569 {
int bar() { return 7; }
}

struct Bug3569b {
Bug3569 foo;
void crash() {
static assert(!is(typeof(Compileable!(foo.bar();
static assert(!is(typeof(Compileable!((foo = Bug3569.init).bar();
}
}


PATCH
Index: interpret.c
===
--- interpret.c(revision 524)
+++ interpret.c(working copy)
@@ -1110,8 +1110,9 @@

 Expression *ThisExp::interpret(InterState *istate)
 {
-if (istate-localThis)
+if (istate  istate-localThis)
 return istate-localThis-interpret(istate);
+error(value of 'this' is not known at compile time);
 return EXP_CANT_INTERPRET;
 }

@@ -2105,6 +2106,11 @@
 #endif
 Expression *e = EXP_CANT_INTERPRET;
 Expression *e1 = this-e1;
+if (!istate)
+{
+error(value of %s is not known at compile time, e1-toChars());
+return e;
+}

 if (fp)
 {

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


[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

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



--- Comment #3 from Don clugd...@yahoo.com.au 2010-01-22 00:09:28 PST ---
Svn commit 337 gets rid of the stack overflow, and turns it into a
rejects-valid bug.

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


[Issue 3569] DMD Stack Overflow with a struct member function inside a C-style struct initializer

2009-12-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3569


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

   What|Removed |Added

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


--- Comment #2 from Don clugd...@yahoo.com.au 2009-12-29 12:32:09 PST ---
This patch to AssertExp::interpret() prevents the stack overflow, turning it
into a simple error message. It doesn't patch the regression.
As Rob notes, the static struct initializers are evaluated at compile time, but
they shouldn't be. Nonetheless, this patch is still required to prevent
segfaults in the case where they are forcibly evaluated at compile time. Eg,
code like the following:

struct Foo {
Foo bar() { return this; }
}

struct Bar {
Foo foo;
int fog() {
enum Bar r = { foo.bar() };
return 3;
}
}

PATCH ---

Index: interpret.c
===
--- interpret.c(revision 318)
+++ interpret.c(working copy)
@@ -2535,14 +2535,18 @@
 if( this-e1-op == TOKaddress)
 {   // Special case: deal with compiler-inserted assert(this, null
this) 
 AddrExp *ade = (AddrExp *)this-e1;
-if(ade-e1-op == TOKthis  istate-localThis)   
-return istate-localThis-interpret(istate);
+if(ade-e1-op == TOKthis  istate-localThis)
+if (istate-localThis-op==TOKdotvar
+   ((DotVarExp *)(istate-localThis))-e1-op==TOKthis)
+return getVarExp(loc, istate, ((DotVarExp
*)(istate-localThis))-var);
+else 
+return istate-localThis-interpret(istate);
 }
-if (this-e1-op == TOKthis)
-{
+if (this-e1-op == TOKthis)
+{
 if(istate-localThis)   
-return istate-localThis-interpret(istate);
-}
+return istate-localThis-interpret(istate);
+}
 e1 = this-e1-interpret(istate);
 if (e1 == EXP_CANT_INTERPRET)
 goto Lcant;

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