Function attribute deduction depends on compile invocation

Nicholas Wilson via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 15 06:30:53 PDT 2017


On Saturday, 15 July 2017 at 12:29:09 UTC, Johan Engelen wrote:
> On Friday, 14 July 2017 at 23:51:24 UTC, Walter Bright wrote:
>> On 7/14/2017 9:53 AM, Johan Engelen wrote:
>>> What happens in that in one kind of compilation, @nogc is 
>>> deduced for a function. But in another compilation, it isn't. 
>>> Thus references to the function will have the wrong mangling, 
>>> and linker errors happen:
>>> https://issues.dlang.org/show_bug.cgi?id=17541
>>
>> At the moment you can work around it by explicitly adding the 
>> annotation.
>
> Cannot add something to a compiler internal function (e.g. 
> __fieldPostblit), @nogc and pure are infectious, the templates 
> are instantiated with different types where some instantiations 
> require deducing @nogc/pure/..., others require @gc/impure/..., 
> annotations cannot be applied conditionally (at least I don't 
> know how), cannot add @gc, cannot add @impure, etc.

Not that it helps you at the moment, but thus is addressed by my 
attributes DIP.

I suppose you could abuse @allocSize to force @gc, but thats very 
ugly.


More information about the Digitalmars-d mailing list