-preview=in might break code

kinke noone at nowhere.com
Sun Oct 4 23:17:03 UTC 2020


On Sunday, 4 October 2020 at 23:06:58 UTC, Ola Fosheim Grøstad 
wrote:
> You need to know the implementation as parameters can alias 
> with globals accessed by the function. So not caller only.

As-is with all refs today:

struct S { int a; }

int* p;

int foo(const scope ref S s)
{
     *p = 123;
     return s.a;
}

void main()
{
     S s;
     p = &s.a;
     assert(foo(s) == 0); // oops
}


More information about the Digitalmars-d mailing list