Comment #0 by bearophile_hugs — 2014-02-18T13:40:56Z
void main() {
int[1] a, b;
a[] = a[];
a[] = a[] + b[];
a[] = a[] * 2;
}
With DMD 2.065rc1 that code compiles, and then it gives at run-time:
object.Error: Overlapping arrays in vector operation: 4 byte(s) overlap of 4
I suggest to catch similar basic cases at compile-time.
Comment #1 by lio+bugzilla — 2016-05-16T11:34:44Z
I ran into this as well and also think the compiler should make a best effort to detect this at compile time, to minimize run-time surprises.
I'm pretty far along with a patch, but am running into corner cases. Will push soon to get some feedback.
Comment #2 by nick — 2023-07-05T13:16:11Z
With dmd v2.104.0, this is the only line that fails:
> a[] = a[];
Even this works:
a[] = b[] / a[];
So it's not just rewriting it as `op=`.
Comment #3 by robert.schadek — 2024-12-13T18:17:07Z