Discussion Thread: DIP 1038-- at nodiscard--Final Review

claptrap clap at trap.com
Fri Feb 5 14:09:09 UTC 2021


On Friday, 5 February 2021 at 11:35:34 UTC, Paul Backus wrote:
> On Friday, 5 February 2021 at 08:33:21 UTC, claptrap wrote:

> Remember that the compiler already produces a warning (not an 
> error) if you discard the return value of a `pure nothrow` 
> function, which includes most std.math functions:
>
>     void main()
>     {
>         import std.math;
>         sqrt(2.0);
>     }
>
> Compile with `dmd -wi` and you get:
>
> onlineapp.d(4): Warning: calling std.math.sqrt without side 
> effects discards return value of type double, prepend a 
> cast(void) if intentional
>
> https://run.dlang.io/is/cE80Uv

Tbh i didnt even know D had warnings, nor that it warned about 
unused returns.

Cant see the point with stuff like sqrt() though.


More information about the Digitalmars-d mailing list