Bug 1058 – DMD hangs with 100% CPU - member function returning forward-referenced struct before constructor

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-03-12T19:26:00Z
Last change time
2014-02-16T15:25:25Z
Keywords
ice-on-valid-code
Assigned to
bugzilla
Creator
vlasov
Blocks
340

Comments

Comment #0 by vlasov — 2007-03-12T19:26:09Z
DMD 1.009 and 1.007 hangs compiling that: ---- module test.d module test; class A { B _b; B b() { return _b; } protected this() {} } struct B { } ---- output >dmd -c test.d -v parse test semantic test import object (c:\dmd\bin\..\src\phobos\object.d)
Comment #1 by smjg — 2007-03-14T14:19:05Z
The spec doesn't make it obvious whether empty structs are supposed to be allowed. But they show up as being one byte in size when I experiment.
Comment #2 by vlasov — 2007-03-14T14:35:12Z
yes, seems i tried too hard to provide as small example as possible ;-) it still hang if struct contain members. moving constructor above "B _b" makes compiler happy.
Comment #3 by smjg — 2007-03-15T10:42:35Z
I've tried a few different permutations, and it appears that the bug shows as long as A is defined before B, and b() is defined before this().
Comment #4 by thomas-dloop — 2007-03-29T14:08:34Z
Comment #5 by nick.atamas — 2007-07-07T17:05:30Z
This also hangs the compiler with 100% CPU usage. Not sure if this is the same issue or a different one, but it certainly looks similar. Should it be added to DStress? Note the comments sample - moving the declaration up or removing static from declaration of makeS() fixes the hang issue. class Klass { protected S _s; public void one() { makesS(); } //Move this up to fix hang struct S{int a;} //Making this non-static fixes hang protected static S makesS() { S s; return s; } } int main(){return 0;}
Comment #6 by wbaxter — 2007-07-08T18:54:00Z
This looks a lot like bug 1206 too. http://d.puremagic.com/issues/show_bug.cgi?id=1206 1206 is marked "Fixed DMD 1.018 and DMD 2.002". Does this bug still occur in those versions of DMD?
Comment #7 by nick.atamas — 2007-07-08T19:01:22Z
(In reply to comment #6) > This looks a lot like bug 1206 too. > http://d.puremagic.com/issues/show_bug.cgi?id=1206 > > 1206 is marked "Fixed DMD 1.018 and DMD 2.002". > > Does this bug still occur in those versions of DMD? > The sample I provided works fine in 1.018.
Comment #8 by davidl — 2007-09-20T04:06:17Z
i tested with dmd 1.021 seems already get fixed