Does slicing have an effect?

rikki cattermole rikki at cattermole.co.nz
Tue May 21 20:44:49 UTC 2019


On 22/05/2019 8:31 AM, Dennis wrote:
> I was replacing a memcpy with a slice assignment and accidentally used 
> == instead of =.
> Usually the compiler protects me from mistakes like that:
> 
> ```
> int[4] a;
> a == a;
> ```
> Error: a == a has no effect
> 
> However, because I was using slices it didn't:
> ```
> int[4] a;
> a[] == a[];
> ```
> No errors
> 
> Does slicing have an effect I'm not aware of, or is this a bug?

It could have an effect if a was a struct/class via operator overloads. 
But in this case it should probably be a bug.


More information about the Digitalmars-d-learn mailing list