-preview=in might break code

Paul Backus snarwin at gmail.com
Sun Oct 4 01:43:45 UTC 2020


On Saturday, 3 October 2020 at 21:36:00 UTC, Mathias LANG wrote:
> A platform dependent change of lvalue-ness is trivial to craft 
> using only `auto ref`:
> ```
> void foo () (auto ref size_t value)
> {
>     pragma(msg, __traits(isRef, value));
> }
> auto ref size_t platform (uint* param) { return *param; }
> extern(C) void main ()
> {
>     uint value;
>     foo(platform(&value));
> }
> ```
>
> Tested on Linux64:
> ```
> % dmd -betterC -run previn.d
> false
> % dmd -betterC -m32 -run previn.d
> true
> ```

This is a great illustration of the gotchas inherent in using 
variable-sized integer types like `size_t`.


More information about the Digitalmars-d mailing list