dip1000 + pure is a DEADLY COMBO
Per Nordlöw
per.nordlow at gmail.com
Fri May 14 09:43:20 UTC 2021
On Friday, 14 May 2021 at 09:02:35 UTC, Per Nordlöw wrote:
> I fail to see the general issue here.
Nevermind this comment. I see the problem now, thanks. I was
given the code example
```d
int bad_global = 1;
@safe pure void purefunc(int* x)
{
*x = 2;
}
void main()
{
assert(bad_global == 1);
purefunc(&bad_global);
assert(bad_global == 2);
}
```
that incorrectly succeeds to compile [1].
[1]
https://run.dlang.io/?compiler=dmd&source=int%20bad_global%20%3D%201;%0Apure%20void%20purefunc(int*%20x)%0A%7B%0A%20%20%20%20*x%20%3D%202;%0A%7D%0Avoid%20main()%0A%7B%0A%20%20%20%20assert(bad_global%20%3D%3D%201);%0A%20%20%20%20purefunc(%26bad_global);%0A%20%20%20%20assert(bad_global%20%3D%3D%202);%0A%7D
More information about the Digitalmars-d
mailing list