• Matthew Dempsky's avatar
    cmd/compile: fix evaluation order for OASOP · 34db5f0c
    Matthew Dempsky authored
    Currently, we handle "x op= y" by rewriting as "x = x op y", while
    ensuring that any calls or receive operations in 'x' are only
    evaluated once. Notably, pointer indirection, indexing operations,
    etc. are left alone as it's typically safe to re-evaluate those.
    
    However, those operations were interleaved with evaluating 'y', which
    could include function calls that might cause re-evaluation to yield
    different memory addresses.
    
    As a fix, simply ensure that we order side-effecting operations in 'y'
    before either evaluation of 'x'.
    
    Fixes #21687.
    
    Change-Id: Ib14e77760fda9c828e394e8e362dc9e5319a84b2
    Reviewed-on: https://go-review.googlesource.com/60091
    Run-TryBot: Matthew Dempsky <mdempsky@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarDavid Chase <drchase@google.com>
    34db5f0c
issue21687.go 940 Bytes