www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Infinite loop in compiler with forward reference

reply Justin Johansson <no spam.com> writes:
Compiling the following with latest DMD D2 sends the compiler into an
infinite loop.  The culprit line seems to be the alias definition.
Can someone else please confirm.
Thanks Justin




module test;


class Base
{
    Base foo();
}

class Foo: Base
{
    static class Bar: Foo
    {
       Bar foo() {
          return this;
       }
    }

    Bar foo();
}

alias Foo.Bar FooBar;


void main()
{
}



test.d(10): Error: class test.Foo is forward referenced when looking for 
'eVr'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'eWr'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'eXr'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'eYr'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'eZr'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e0r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e1r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e2r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e3r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e4r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e5r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e6r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e7r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e8r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e9r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'e_r'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'eaar'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'ebar'
test.d(10): Error: class test.Foo is forward referenced when looking for 
'ecar'
....
Aug 13 2010
next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
--000e0cd5ccdc83f72e048dbd3172
Content-Type: text/plain; charset=ISO-8859-1

Yup, infinite loop.

On Sat, Aug 14, 2010 at 1:39 AM, Justin Johansson <no spam.com> wrote:

 Compiling the following with latest DMD D2 sends the compiler into an
 infinite loop.  The culprit line seems to be the alias definition.
 Can someone else please confirm.
 Thanks Justin




 module test;


 class Base
 {
   Base foo();
 }

 class Foo: Base
 {
   static class Bar: Foo
   {
      Bar foo() {
         return this;
      }
   }

   Bar foo();
 }

 alias Foo.Bar FooBar;


 void main()
 {
 }



 test.d(10): Error: class test.Foo is forward referenced when looking for
 'eVr'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'eWr'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'eXr'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'eYr'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'eZr'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e0r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e1r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e2r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e3r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e4r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e5r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e6r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e7r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e8r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e9r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'e_r'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'eaar'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'ebar'
 test.d(10): Error: class test.Foo is forward referenced when looking for
 'ecar'
 ....

--000e0cd5ccdc83f72e048dbd3172 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Yup, infinite loop.<br><br><div class=3D"gmail_quote">On Sat, Aug 14, 2010 = at 1:39 AM, Justin Johansson <span dir=3D"ltr">&lt;<a href=3D"mailto:no spa= m.com">no spam.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quot= e" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204,= 204); padding-left: 1ex;"> Compiling the following with latest DMD D2 sends the compiler into an<br> infinite loop. =A0The culprit line seems to be the alias definition.<br> Can someone else please confirm.<br> Thanks Justin<br> <br> <br> <br> <br> module test;<br> <br> <br> class Base<br> {<br> =A0 Base foo();<br> }<br> <br> class Foo: Base<br> {<br> =A0 static class Bar: Foo<br> =A0 {<br> =A0 =A0 =A0Bar foo() {<br> =A0 =A0 =A0 =A0 return this;<br> =A0 =A0 =A0}<br> =A0 }<br> <br> =A0 Bar foo();<br> }<br> <br> alias Foo.Bar FooBar;<br> <br> <br> void main()<br> {<br> }<br> <br> <br> <br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;eVr&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;eWr&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;eXr&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;eYr&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;eZr&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e0r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e1r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e2r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e3r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e4r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e5r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e6r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e7r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e8r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e9r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;e_r&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;eaar&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;ebar&#39;<br> test.d(10): Error: class test.Foo is forward referenced when looking for &#= 39;ecar&#39;<br> ....<br> </blockquote></div><br> --000e0cd5ccdc83f72e048dbd3172--
Aug 13 2010
parent Era Scarecrow <rtcvb32 yahoo.com> writes:
== Quote from Andrej Mitrovic (andrej.mitrovich gmail.com)'s article
 --000e0cd5ccdc83f72e048dbd3172
 Content-Type: text/plain; charset=ISO-8859-1
 Yup, infinite loop.
 On Sat, Aug 14, 2010 at 1:39 AM, Justin Johansson <no spam.com> wrote:
 Compiling the following with latest DMD D2 sends the compiler into an
 infinite loop.  The culprit line seems to be the alias definition.
 Can someone else please confirm.
 Thanks Justin


Not with GDC, but that may not be important. $ gdc --version gdc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gdc test.d /tmp/ccubltma.o:test.d:(.rdata+0x28): undefined reference to `__D4test4Base3fooF ZC4test4Base' /tmp/ccubltma.o:test.d:(.rdata+0x78): undefined reference to `__D4test3Foo3fooFZ C4test3Foo3Bar' collect2: ld returned 1 exit status $
Aug 13 2010
prev sibling next sibling parent Jonathan M Davis <jmdavisprog gmail.com> writes:
On Friday 13 August 2010 20:01:40 Era Scarecrow wrote:
 == Quote from Andrej Mitrovic (andrej.mitrovich gmail.com)'s article
 
 --000e0cd5ccdc83f72e048dbd3172
 Content-Type: text/plain; charset=ISO-8859-1
 Yup, infinite loop.
 
 On Sat, Aug 14, 2010 at 1:39 AM, Justin Johansson <no spam.com> wrote:
 Compiling the following with latest DMD D2 sends the compiler into an
 infinite loop.  The culprit line seems to be the alias definition.
 Can someone else please confirm.
 Thanks Justin


Not with GDC, but that may not be important.

Well, it's a bug. Regardless of how well gdc follows the D2 spec (and from what I understand, it's a fair bit behind at this point), both dmd and gdc are going to have bugs, and those bugs are going to be different. So, the fact that something works or not with dmd doesn't say much about whether it works with gdc (or vice versa) unless you're talking about language spec issues. Bugs are naturally going to differ between the two. - Jonathan M davis
Aug 13 2010
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
--001485e7e8489fdaae048dbff7cd
Content-Type: text/plain; charset=ISO-8859-1

dmd 0.125? Isn't that ancient? :)

On Sat, Aug 14, 2010 at 5:01 AM, Era Scarecrow <rtcvb32 yahoo.com> wrote:

 == Quote from Andrej Mitrovic (andrej.mitrovich gmail.com)'s article
 --000e0cd5ccdc83f72e048dbd3172
 Content-Type: text/plain; charset=ISO-8859-1
 Yup, infinite loop.
 On Sat, Aug 14, 2010 at 1:39 AM, Justin Johansson <no spam.com> wrote:
 Compiling the following with latest DMD D2 sends the compiler into an
 infinite loop.  The culprit line seems to be the alias definition.
 Can someone else please confirm.
 Thanks Justin


Not with GDC, but that may not be important. $ gdc --version gdc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gdc test.d /tmp/ccubltma.o:test.d:(.rdata+0x28): undefined reference to `__D4test4Base3fooF ZC4test4Base' /tmp/ccubltma.o:test.d:(.rdata+0x78): undefined reference to `__D4test3Foo3fooFZ C4test3Foo3Bar' collect2: ld returned 1 exit status $

--001485e7e8489fdaae048dbff7cd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable dmd 0.125? Isn&#39;t that ancient? :)<br><br><div class=3D"gmail_quote">On = Sat, Aug 14, 2010 at 5:01 AM, Era Scarecrow <span dir=3D"ltr">&lt;<a href= =3D"mailto:rtcvb32 yahoo.com">rtcvb32 yahoo.com</a>&gt;</span> wrote:<br><b= lockquote class=3D"gmail_quote" style=3D"margin: 0pt 0pt 0pt 0.8ex; border-= left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"> =3D=3D Quote from Andrej Mitrovic (<a href=3D"mailto:andrej.mitrovich gmail= .com">andrej.mitrovich gmail.com</a>)&#39;s article<br> &gt; --000e0cd5ccdc83f72e048dbd3172<br> &gt; Content-Type: text/plain; charset=3DISO-8859-1<br> <div class=3D"im">&gt; Yup, infinite loop.<br> &gt; On Sat, Aug 14, 2010 at 1:39 AM, Justin Johansson &lt;<a href=3D"mailt= o:no spam.com">no spam.com</a>&gt; wrote:<br> </div><div class=3D"im">&gt; &gt; Compiling the following with latest DMD D= 2 sends the compiler into an<br> &gt; &gt; infinite loop. =A0The culprit line seems to be the alias definiti= on.<br> &gt; &gt; Can someone else please confirm.<br> &gt; &gt; Thanks Justin<br> &gt; &gt;<br> <br> </div>=A0Not with GDC, but that may not be important.<br> <br> $ gdc --version<br> gdc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)<br> Copyright (C) 2004 Free Software Foundation, Inc.<br> This is free software; see the source for copying conditions. =A0There is N= O<br> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.= <br> <br> $ gdc test.d<br> /tmp/ccubltma.o:test.d:(.rdata+0x28): undefined reference to `__D4test4Base= 3fooF<br> ZC4test4Base&#39;<br> /tmp/ccubltma.o:test.d:(.rdata+0x78): undefined reference to `__D4test3Foo3= fooFZ<br> C4test3Foo3Bar&#39;<br> collect2: ld returned 1 exit status<br> <br> $<br> </blockquote></div><br> --001485e7e8489fdaae048dbff7cd--
Aug 13 2010
prev sibling parent Leandro Lucarella <luca llucax.com.ar> writes:
Era Scarecrow, el 14 de agosto a las 03:01 me escribiste:
 == Quote from Andrej Mitrovic (andrej.mitrovich gmail.com)'s article
 --000e0cd5ccdc83f72e048dbd3172
 Content-Type: text/plain; charset=ISO-8859-1
 Yup, infinite loop.
 On Sat, Aug 14, 2010 at 1:39 AM, Justin Johansson <no spam.com> wrote:
 Compiling the following with latest DMD D2 sends the compiler into an
 infinite loop.  The culprit line seems to be the alias definition.
 Can someone else please confirm.
 Thanks Justin


Not with GDC, but that may not be important. $ gdc --version gdc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

Note that you're using an ancient compiler. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Con vos hay pica, patovica! -- Sidharta Kiwi
Aug 13 2010