• David Chase's avatar
    cmd/compile: ensure that operand of ORETURN is not double-walked · c359d759
    David Chase authored
    Inlining of switch statements into a RETURNed expression
    can sometimes lead to the switch being walked twice, which
    results in a miscompiled switch statement. The bug depends
    on:
    
    1) multiple results
    2) named results
    3) a return statement whose expression includes a call to a
    function containing a switch statement that is inlined.
    
    It may also be significant that the default case of that
    switch is a panic(), though that's not proven.
    
    Rearranged the walk case for ORETURN so that double walks are
    not possible.  Added a test, because this is so fiddly.
    Added a check against double walks, verified that it fires
    w/o other fix.
    
    Fixes #25776.
    
    Change-Id: I2d594351fa082632512ef989af67eb887059729b
    Reviewed-on: https://go-review.googlesource.com/118318
    Run-TryBot: David Chase <drchase@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
    c359d759
swt.go 26.9 KB