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().
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;}
(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.