Most basic nothrow, pure, @safe functions?

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 20 18:52:18 PDT 2014


On Thu, 20 Mar 2014 21:44:38 -0400, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>
>> This is also a pure function:
>>
>> pure int foo()
>> {
>>    while(1) {}
>>    return 0;
>> }
>>
>> Pure doesn't mean "bug free".
>
> Thankfully the D compiler catches the bug :-)
>
> test.d(3,4): Warning: statement is not reachable

I can make it not catch that error, but that is not the bug. The bug is  
that it never returns, effectively deadlocking. The sample is  
intentionally short to demonstrate my point, I (obviously) didn't try to  
compile it.

-Steve


More information about the Digitalmars-d mailing list