• Alberto Donizetti's avatar
    cmd/compile: prevent overflow in walkinrange · 42cc4ca3
    Alberto Donizetti authored
    In the compiler frontend, walkinrange indiscriminately calls Int64()
    on const CTINT nodes, even though Int64's return value is undefined
    for anything over 2⁶³ (in practise, it'll return a negative number).
    
    This causes the introduction of bad constants during rewrites of
    unsigned expressions, which make the compiler reject valid Go
    programs.
    
    This change introduces a preliminary check that Int64() is safe to
    call on the consts on hand. If it isn't, walkinrange exits without
    doing any rewrite.
    
    Fixes #27143
    
    Change-Id: I2017073cae65468a521ff3262d4ea8ab0d7098d9
    Reviewed-on: https://go-review.googlesource.com/130735
    Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
    42cc4ca3
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...