3 ms·
It'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 ...
by gowld 8y ago
It'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]