How can I tell D that function args are @nogc etc.

John Dougan jdougan at acm.org
Fri Apr 12 03:57:40 UTC 2024


On Thursday, 11 April 2024 at 15:00:49 UTC, Steven Schveighoffer 
wrote:
>
> So D can provide a nice mechanism to show what is happening -- 
> `pragma(msg, ...)`
>
> If I do that with the two types above I see something *very* 
> interesting:
>
> ```d
> pragma(msg, FnPrefixT);
> pragma(msg, FnSuffixT);
> ```
>
> ```
> bool function(int) nothrow @nogc
> bool function(int) nothrow @nogc @safe
> ```
>
> That surprises me. `nothrow` and `@nogc` go onto the type, but 
> not `@safe` if put before the declaration? I have no idea why. 
> All I can think of is that it is a bug.
>

`pragma(msg,...)` is very useful. Thanks.

My general impressions were correct then. It shouldn't matter on 
which side the attrs get put, except in some ambiguous cases. 
It's just broken. Not every day you get to blame a compiler bug.

Feeding:
```d
alias FnPrefixT = @safe nothrow @nogc bool function(int);
alias FnSuffixT = bool function(int) @safe nothrow @nogc ;

pragma(msg, FnPrefixT);
pragma(msg, FnSuffixT);

void main() { return; }
```

into run.dlang and having it compile with all the 
compilers...gets the same result all the way back to 2.060. It 
has this issue with gdc 2.076, which is what I'm using normally.

What is the procedure for bug reporting? I'm looking at the 
issues tracker and have no clue how to drive the search to see if 
this is already there.

>
> -Steve

-- john



More information about the Digitalmars-d-learn mailing list