How to get nogc to work with manual memory allocation

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 24 05:18:41 PDT 2014


On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote:
> On 2014-08-24 10:03, Bienlein wrote:
>
>> I have omitted the code for the TestClass class to save space. 
>> Problem
>> is that the compiler outputs this:
>>
>> Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' 
>> cannot call
>> non- at nogc function 'core.exception.onOutOfMemoryError'
>> Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew' 
>> cannot call
>> non- at nogc function 'std.conv.emplace!(TestClass, ).emplace'
>> Error: @nogc function 'main.nogcDel!(TestClass).nogcDel' 
>> cannot call
>> non- at nogc function 'object.destroy!(TestClass).destroy'
>>
>> Is there a way to get around this?
>
> @nogc is a very new attribute. The runtime and standard library 
> have not been properly annotated with this attribute yet.
>
> As a workaround you could try copy implementation of these 
> functions to you're own code and annotate them as appropriate.

Shouldn't emplace and destroy infer their attributes instead of 
strictly annotating them as nogc.


More information about the Digitalmars-d-learn mailing list