Passing delegate indirectly to createLowLevelThread doesn't work

JG JG at somewhere.com
Mon Jul 26 17:01:13 UTC 2021


On Monday, 26 July 2021 at 16:46:40 UTC, Tejas wrote:
> On Monday, 26 July 2021 at 15:42:44 UTC, Paul Backus wrote:
>> On Monday, 26 July 2021 at 15:29:26 UTC, Tejas wrote:
>>> ```d
>>> import std;
>>> import core.thread.osthread;
>>>
>>> void delegate() f;
>>> void main()
>>> {
>>>     void func(){}
>>>     f = &func;
>>>     createLowLevelThread(&func, 2<<30);//works
>>>     createLowLevelThread(f, 2<<30);// doesn't  work!!
>>> }
>>>
>>> ```
>>>
>>> Can someone help?
>>
>> The delegate must be `nothrow`:
>>
>> ```d
>> void delegate() nothrow f;
>> ```
>
> Doesn't seem to matter. I tried that beforehand. And even if it 
> did why does passing it directly work without explicitly 
> qualifying it as nothrow then?

It does work for me. To me running the following explains why:

```d
import std;
import core.thread.osthread;

void delegate() f;
void main()
{
     void func(){}
     f = &func;
     pragma(msg,typeof(&func));
     pragma(msg,typeof(f));
     createLowLevelThread(&func, 2<<30);//works
     //createLowLevelThread(f, 2<<30);// doesn't  work!!
}
```



More information about the Digitalmars-d-learn mailing list