@JoachimPileborg: a const reference doesn't tell the referenced object is constant, but only that you cannot mutate it
using that reference: the object can still mutate because of aliasing or other accesses. The optimizer simply totally ignores const-ness of references... they were designed as an aid for programmers, not for the compiler (I'm also not sure at all they really help the programmers, but that's another story). —
6502 1 min ago