D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3101 - Stack overflow: declaring aggregate member twice with static if
Summary: Stack overflow: declaring aggregate member twice with static if
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2009-06-28 18:23 UTC by Jason House
Modified: 2014-04-18 09:12 UTC (History)
2 users (show)

See Also:


Attachments
file demonstrating issue (231 bytes, text/x-dsrc)
2009-06-28 18:28 UTC, Jason House
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Jason House 2009-06-28 18:23:56 UTC
The attached code demonstrates the issue.  Below is the compilation command used to reproduce the bug (and the output from dmd before it hung)
dmd -gc -O -release main.d -ofmain
error: foo is not shared (1)
main.d(4): Error: declaration T is already defined
Comment 1 Jason House 2009-06-28 18:28:35 UTC
Created attachment 407 [details]
file demonstrating issue
Comment 2 Don 2009-07-09 04:56:58 UTC
Reduced test case (Windows):

---
struct foo{
  static if (is(int T == int)) {}
  static if (is(int T == int)) {}
}
----
> dmd ice.d
ice.d(3): Error: declaration T is already defined
Stack overflow

On DMD1, it stack overflows without error message.
Comment 3 Don 2009-08-12 11:26:48 UTC
Patch is very easy.

in int AliasDeclaration::overloadInsert(Dsymbol *s), make sure it doesn't call itself.


Index: declaration.c
===================================================================
--- declaration.c	(revision 194)
+++ declaration.c	(working copy)
@@ -543,6 +543,8 @@
     {	overnext = s;
 	return TRUE;
     }
+    else if (overnext==this) // a recursive expansion would ensue. Bugzilla 3101
+       return FALSE;
     else
     {
 	return overnext->overloadInsert(s);
Comment 4 Walter Bright 2009-10-13 13:45:47 UTC
Fixed dmd 1.049 and 2.034