www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - dmd 125 bug? compiles and seg faults...

reply clayasaurus <clayasaurus gmail.com> writes:
is seg faulting the desired behavior of this code?

-------------------------------------------------------------------

import std.stdio;

int main()
{
    Two thy = new Two;

    thy.print();

    return 0;
}


class One
{
    void print()
    {
       writefln("Hello");
    }
}

class Two : One
{
    void print()
    {
       One:print();
       writefln("There");
    }
}

-------------------------------------------------------------------

I wrote this while trying to rediscover inheritance. Anyway, I found 
super.print() works.
May 23 2005
next sibling parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
Yours:

void print()
   {
       print();
   }

will produce "Stack overflow". 
May 23 2005
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"clayasaurus" <clayasaurus gmail.com> wrote in message
news:d6tven$2g4r$1 digitaldaemon.com...
 import std.stdio;

 int main()
 {
     Two thy = new Two;

     thy.print();

     return 0;
 }


 class One
 {
     void print()
     {
        writefln("Hello");
     }
 }

 class Two : One
 {
     void print()
     {
        One:print();

Replacing the ':' with a '.' and it exhibits the behavior you're looking for. The One:print(); is parsed as One being a label, then the print() recursively calls itself till the stack overflows.
        writefln("There");
     }
 }

May 23 2005
parent reply Roberto Mariottini <Roberto_member pathlink.com> writes:
In article <d6uir1$30uc$1 digitaldaemon.com>, Walter says...

     void print()
     {
        One:print();

Replacing the ':' with a '.' and it exhibits the behavior you're looking for. The One:print(); is parsed as One being a label, then the print() recursively calls itself till the stack overflows.

Time for an Obfuscated D contest! ;-) Ciao
May 24 2005
next sibling parent "Walter" <newshound digitalmars.com> writes:
"Roberto Mariottini" <Roberto_member pathlink.com> wrote in message
news:d6ujrt$s0$1 digitaldaemon.com...
 Time for an Obfuscated D contest! ;-)

Ouch!
May 24 2005
prev sibling parent reply David Medlock <noone nowhere.com> writes:
Roberto Mariottini wrote:

 In article <d6uir1$30uc$1 digitaldaemon.com>, Walter says...
 
 [...]
 
    void print()
    {
       One:print();

Replacing the ':' with a '.' and it exhibits the behavior you're looking for. The One:print(); is parsed as One being a label, then the print() recursively calls itself till the stack overflows.

Time for an Obfuscated D contest! ;-) Ciao

-DavidM
May 24 2005
parent reply "Walter" <newshound digitalmars.com> writes:
"David Medlock" <noone nowhere.com> wrote in message
news:d70at4$2hvq$1 digitaldaemon.com...
 Roberto Mariottini wrote:

 In article <d6uir1$30uc$1 digitaldaemon.com>, Walter says...
    void print()
    {
       One:print();

Replacing the ':' with a '.' and it exhibits the behavior you're looking for. The One:print(); is parsed as One being a label, then the print() recursively calls itself till the stack overflows.

Time for an Obfuscated D contest! ;-)


Long ago, the C'ith Lord mastered the dark secrets of the goto and the pointer to gain unprecedented levels of power, using it to betray and slaughter the Javi Knights. A dark age of buffer overflows and gp faults ensued, and many systems were ravaged by virus attacks. But from the fatal loins of the C'ith Lord spawned a new hope, Duke Arraywalker, with power greater than even the C'ith could imagine. But Duke is young and unproven. Will he apprentice with the exiled Javi? Will he learn the unix ways of the Source? Will he prevail in the coming battle with the C'ith Lord? Or will he be seduced by the dark side of the goto and the pointer? Stay tuned!
May 25 2005
next sibling parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
:) 
May 25 2005
prev sibling next sibling parent John Reimer <brk_6502 yahoo.com> writes:
Walter wrote:
 Long ago, the C'ith Lord mastered the dark secrets of the goto and the
 pointer to gain unprecedented levels of power, using it to betray and
 slaughter the Javi Knights. A dark age of buffer overflows and gp faults
 ensued, and many systems were ravaged by virus attacks. But from the fatal
 loins of the C'ith Lord spawned a new hope, Duke Arraywalker, with power
 greater than even the C'ith could imagine.
 
 But Duke is young and unproven. Will he apprentice with the exiled Javi?
 Will he learn the unix ways of the Source? Will he prevail in the coming
 battle with the C'ith Lord? Or will he be seduced by the dark side of the
 goto and the pointer?
 
 Stay tuned!
 
 

That was funny! And to think compiler writing became your chosen profession... ;-) -JJR
May 25 2005
prev sibling next sibling parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
LOL.

-[Unknown]


 Long ago, the C'ith Lord mastered the dark secrets of the goto and the
 pointer to gain unprecedented levels of power, using it to betray and
 slaughter the Javi Knights. A dark age of buffer overflows and gp faults
 ensued, and many systems were ravaged by virus attacks. But from the fatal
 loins of the C'ith Lord spawned a new hope, Duke Arraywalker, with power
 greater than even the C'ith could imagine.
 
 But Duke is young and unproven. Will he apprentice with the exiled Javi?
 Will he learn the unix ways of the Source? Will he prevail in the coming
 battle with the C'ith Lord? Or will he be seduced by the dark side of the
 goto and the pointer?
 
 Stay tuned!

May 25 2005
prev sibling parent Dave <Dave_member pathlink.com> writes:
In article <d7287c$30af$1 digitaldaemon.com>, Walter says...
"David Medlock" <noone nowhere.com> wrote in message
news:d70at4$2hvq$1 digitaldaemon.com...
 Roberto Mariottini wrote:

 In article <d6uir1$30uc$1 digitaldaemon.com>, Walter says...
    void print()
    {
       One:print();

Replacing the ':' with a '.' and it exhibits the behavior you're looking for. The One:print(); is parsed as One being a label, then the print() recursively calls itself till the stack overflows.

Time for an Obfuscated D contest! ;-)


Long ago, the C'ith Lord mastered the dark secrets of the goto and the pointer to gain unprecedented levels of power, using it to betray and slaughter the Javi Knights. A dark age of buffer overflows and gp faults ensued, and many systems were ravaged by virus attacks. But from the fatal loins of the C'ith Lord spawned a new hope, Duke Arraywalker, with power greater than even the C'ith could imagine. But Duke is young and unproven. Will he apprentice with the exiled Javi? Will he learn the unix ways of the Source? Will he prevail in the coming battle with the C'ith Lord? Or will he be seduced by the dark side of the goto and the pointer? Stay tuned!

LOL. This one is destined for my archive drive <g>
May 27 2005