3 ms·
I mean, that's fairly broken given the way developers expect operators to be applied. The ease of avoidance is unrelated to whether it's broken behavior or not
by reificator 8y ago
I mean, that's fairly broken given the way developers expect operators to be applied.
The ease of avoidance is unrelated to whether it's broken behavior or not.
- gowld 8y agoIt's a bug for sure, but anyone who cares about correctness ought to be using a style that doesn't allow this tortured contortion: array[i++] += i ...
- esrauch 8y agoThe same bug repros for array[method()] += "string"; where method is invoked twice instead of once.
- simias 8y agoIf I understand correctly "array[i++] += ..." alone is enough to trigger the bug which doesn't seem particularly tortured to me. Actually any "array[side_effect()] +=" would trigger the bug. That's pretty bad IMO.
- seandougall 8y agoEven if the function within the subscript were free if side effects, calling it twice would be a ridiculous performance regression. I’m no compiler developer, but this really seems like a rookie mistake.
- Dylan16807 8y agoDon't focus too much on the first example. array[i++] += "a" is just is broken. So is appending to array[foo()] or foo().field
- deleted 8y ago[deleted]