Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
March 25, 2005 Compiler crash? | ||||
---|---|---|---|---|
| ||||
--[test27.d]-- typedef fn function() fn; fn foo() { return &foo; } void main() { fn p = foo(); p(); } C:\Library\D\src\temp>dmd test27 -g -debug -unittest C:\Library\D\src\temp> The compiler exits with code -1073741819, prints nothing, produces no files etc. Regan |
March 25, 2005 Re: Compiler crash? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath Attachments: | Regan Heath wrote: | --[test27.d]-- | typedef fn function() fn; | | fn foo() { return &foo; } | | void main() | { | fn p = foo(); | p(); | } | | C:\Library\D\src\temp>dmd test27 -g -debug -unittest | | C:\Library\D\src\temp> | | The compiler exits with code -1073741819, prints nothing, produces no | files etc. | | Regan Added to DStress as http://dstress.kuehne.cn/run/debug_info_01.d http://dstress.kuehne.cn/run/debug_info_02.d Thomas |
April 05, 2005 Re: Compiler crash? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | "Regan Heath" <regan@netwin.co.nz> wrote in message news:opsn61vgpg23k2f5@nrage.netwin.co.nz... > --[test27.d]-- > typedef fn function() fn; The circular reference to fn is what causes the crash. I've fixed the compiler to now issue a diagnostic error for it. |
April 05, 2005 Re: Compiler crash? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | On Tue, 5 Apr 2005 15:42:56 -0700, Walter <newshound@digitalmars.com> wrote:
> "Regan Heath" <regan@netwin.co.nz> wrote in message
> news:opsn61vgpg23k2f5@nrage.netwin.co.nz...
>> --[test27.d]--
>> typedef fn function() fn;
>
> The circular reference to fn is what causes the crash. I've fixed the
> compiler to now issue a diagnostic error for it.
Ok. So how does one define/declare a function that returns a function?
Regan
|
April 05, 2005 Re: Compiler crash? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | "Regan Heath" <regan@netwin.co.nz> wrote in message news:opsor7y7x523k2f5@nrage.netwin.co.nz... > On Tue, 5 Apr 2005 15:42:56 -0700, Walter <newshound@digitalmars.com> wrote: > > "Regan Heath" <regan@netwin.co.nz> wrote in message news:opsn61vgpg23k2f5@nrage.netwin.co.nz... > >> --[test27.d]-- > >> typedef fn function() fn; > > > > The circular reference to fn is what causes the crash. I've fixed the compiler to now issue a diagnostic error for it. > > Ok. So how does one define/declare a function that returns a function? It can return a function of a different type. It just can't return a function of the same type. The only way to make the latter work is to use a cast, i.e. declare the function as returning void* and casting the result. |
April 06, 2005 Re: Compiler crash? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote: > On Tue, 5 Apr 2005 15:42:56 -0700, Walter <newshound@digitalmars.com> wrote: > >> "Regan Heath" <regan@netwin.co.nz> wrote in message >> news:opsn61vgpg23k2f5@nrage.netwin.co.nz... >> >>> --[test27.d]-- >>> typedef fn function() fn; >> >> The circular reference to fn is what causes the crash. I've fixed the >> compiler to now issue a diagnostic error for it. > > Ok. So how does one define/declare a function that returns a function? So you can do stuff like fn qwert; qwert = qwert(); You've got me wondering how this could be used in practice.... Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
April 07, 2005 Re: Compiler crash? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | On Wed, 06 Apr 2005 17:00:38 +0100, Stewart Gordon <smjg_1998@yahoo.com> wrote: > Regan Heath wrote: >> On Tue, 5 Apr 2005 15:42:56 -0700, Walter <newshound@digitalmars.com> wrote: >> >>> "Regan Heath" <regan@netwin.co.nz> wrote in message >>> news:opsn61vgpg23k2f5@nrage.netwin.co.nz... >>> >>>> --[test27.d]-- >>>> typedef fn function() fn; >>> >>> The circular reference to fn is what causes the crash. I've fixed the >>> compiler to now issue a diagnostic error for it. >> Ok. So how does one define/declare a function that returns a function? > > So you can do stuff like > > fn qwert; > qwert = qwert(); > > You've got me wondering how this could be used in practice.... Good question.. no idea :) I found the bug when trying to help here.. http://www.digitalmars.com/drn-bin/wwwnews?digitalmars.D/20080 Perhaps ask Brian what he was trying to do with it. Regan |
Copyright © 1999-2021 by the D Language Foundation