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
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
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'
 ....
Aug 13 2010
parent reply 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
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:
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 $
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