Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
May 24, 2005 dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | Yours: void print() { print(); } will produce "Stack overflow". |
May 24, 2005 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to clayasaurus | "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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | "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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roberto Mariottini | 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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Medlock | "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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | :) |
May 25, 2005 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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 Re: dmd 125 bug? compiles and seg faults... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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!
|
Copyright © 1999-2021 by the D Language Foundation