-preview=in might break code

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Oct 5 10:31:56 UTC 2020


On Monday, 5 October 2020 at 00:31:33 UTC, kinke wrote:
> On Sunday, 4 October 2020 at 23:40:29 UTC, Ola Fosheim Grøstad 
> wrote:
>> It might help some if compilers would run unit tests 3 times 
>> with different 'in' implementations.
>>
>> 1 mixed value/ref
>> 2 value
>> 3 ref
>
> I was about to propose something like this (restricted to POD 
> types), possibly augmented by some indeterministic fuzzing. 
> Code ported to the new `in` semantics could then even show some 
> previously unintended aliasing issues; getting to the root of 
> the problem would probably still be non-trivial though.
>
> A compiler mode enforcing by-ref, coupled with some sort of 
> runtime sanitizer detecting invalid writes to live in-params, 
> would probably be a very valuable tool for validation & 
> troubleshooting.

You could do this: make it pass by value as the default, than add 
compiler switches that have increasingly aggressive optimizations 
up to assuming no aliasing.

That ought to be innocent enough.


More information about the Digitalmars-d mailing list