Jump to page: 1 2
Thread overview
dmd 125 bug? compiles and seg faults...
May 24, 2005
clayasaurus
May 24, 2005
Andrew Fedoniouk
May 24, 2005
Walter
May 24, 2005
Roberto Mariottini
May 24, 2005
Walter
May 24, 2005
David Medlock
May 25, 2005
Walter
May 25, 2005
Andrew Fedoniouk
May 25, 2005
John Reimer
May 27, 2005
Dave
May 24, 2005
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 24, 2005
Yours:

void print()
   {
       print();
   }

will produce "Stack overflow".


May 24, 2005
"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 24, 2005
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
"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
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
> 
> 
As suspected, goto (and its labels) are the root of all evil!

-DavidM
May 25, 2005
"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! ;-)
> >
> As suspected, goto (and its labels) are the root of all evil!

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
:)


May 25, 2005
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
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!
« First   ‹ Prev
1 2