www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Compiler crash?

reply "Regan Heath" <regan netwin.co.nz> writes:
--[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
Mar 25 2005
next sibling parent =?ISO-8859-15?Q?Thomas_K=FChne?= writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCRCpL3w+/yD4P9tIRAt3eAKDN8fOsUDHGVNWEyGN/NoH3VKMYYACfYpfx
LJqAiucSuFUaQfH97nVfzGM=
=4jVC
-----END PGP SIGNATURE-----
Mar 25 2005
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"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.
Apr 05 2005
parent reply "Regan Heath" <regan netwin.co.nz> writes:
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
Apr 05 2005
next sibling parent "Walter" <newshound digitalmars.com> writes:
"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.
Apr 05 2005
prev sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
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.
Apr 06 2005
parent "Regan Heath" <regan netwin.co.nz> writes:
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.


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.. digitalmars.D/20080 Perhaps ask Brian what he was trying to do with it. Regan
Apr 06 2005