What output do you think this has, and what do you think it should have / wish it had?

Is this actually RLS aliasing? I think it’s a more basic consequence of left-to-right execution order.

I read this:

As “copy the contents of address b to address a, then copy the contents of address a to address b”.

It certainly rhymes with some of the aliasing problems with RLS, but I think this is just a case of Zig’s sometimes-surprising execution order. In other words, this is an intended result which probably won’t change.

A less surprising way to illustrate this:

a.*, b.* = .{ 42, a.* };

These are both going to be 42, right?

This touches on an earlier conversation about how Zig’s execution semantics can be surprising, but are the right choice for the kind of language it is.

2 Likes