Example (I have to print in a separate function to avoid constant folding): void foo(const int *x1, const int *x2) { import std.stdio: writeln; writeln(*x1, " ", *x2); } void main() { import std.stdio: writeln; int x1; const int x2; import std.algorithm: max, min; auto v = max(&x1, &x2); auto v2 = min(&x1, &x2); *v = 5; *v2 = 5; foo(&x1, &x2); } compiles, prints 5 5, showing x2 has been changed.
This was fixed in DMD v2.094.1 by https://github.com/dlang/phobos/commit/311f00f8ac1e0150139d22ae442358cd707553f8#diff-ac3d3f71b68c353e3e270f4621f707025648e26d9767dc0b2a91549805d12fa6.
Hm... thanks. I wonder if a test case should be added.