Casting delegates to void*

Walter Bright newshound2 at digitalmars.com
Fri Mar 15 14:01:26 PDT 2013


On 3/13/2013 7:32 PM, Daniel Murphy wrote:
> "David Nadlinger" <see at klickverbot.at> wrote in message
> news:kibnaskimiqnmzziegjo at forum.dlang.org...
>> Hi all,
>>
>> A quick quiz: Does the following function compile, and if yes,
>> what will it return?
>>
>> ---
>> void* delegateToPtr(void delegate() dg) {
>>      return cast(void*)dg;
>> }
>> ---
>>
>
> IIRC dg.ptr will be lowered to this, and that is how the glue layer knows
> you want to extract the pointer.  My guess is this predates the .ptr
> property, and much like the array -> ulong cast, should be squashed.
>
>

I agree. Please file an enhancement request for this in bugzilla.


More information about the Digitalmars-d mailing list