Casting delegates to void*

David Nadlinger see at klickverbot.at
Sat Mar 16 03:30:31 PDT 2013


On Friday, 15 March 2013 at 21:01:26 UTC, Walter Bright wrote:
> 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.

http://d.puremagic.com/issues/show_bug.cgi?id=9735

David


More information about the Digitalmars-d mailing list