null to delegate cast?

Stewart Gordon smjg_1998 at yahoo.com
Mon Sep 11 14:26:25 PDT 2006


icee wrote:
> In http://www.digitalmars.com/d/expression.html, you said
> "A null is implicitly converted to a Type delegate() by creating an
> anonymous delegate that returns null."
> 
> But the truth seems not:
> 
> //char[] delegate () dg = null; //cause av

Do you mean:
(a) that merely assigning null to a delegate variable causes an AV?
(b) that calling dg afterwards causes an AV?

(a) certainly shouldn't be happening.  But if (b), of course it does. 
What else would it do?

<snip>
> const Type delegate() dgnull;   // default initializer for delegate is null
> ....
> Type delegate() dg1;  // default initializer for delegate is null
> Type delegate() dg2 = dgnull;
> Type delegate() dg3 = (Type delegate()).init;
> Type delegate() dg4 = cast(Type delegate()) null;
> 
> Type delegate() dg5 = null;  // initializes dg5 to
>                              // delegate Type() { return null; }

Case dg5 is certainly weird.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- 
PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on 
the 'group where everyone may benefit.



More information about the Digitalmars-d-bugs mailing list