https://issues.dlang.org/show_bug.cgi?id=15930
Issue ID: 15930
Summary: min/max of pointers violates const
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: [email protected]
Reporter: [email protected]
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.
--