cmd/compile: hangs compiling hex fp constant
dvyukov opened this issue · 3 comments
go tool compile
hangs in karatsuba compiling the following program:
package a
var e = 1<<1p10000000<<3
Can we just break off hex exponents (p)? They are not supported by go/types-based frontends and so are non-portable.
go version devel +514014c Thu Jun 18 15:54:35 2015 +0200 linux/amd64
Floating-point constants with binary ('p') exponents are not permitted in the source and that has been fixed (issue #9036). E.g.:
package p
const _ = 1p10
is not accepted anymore:
x.go:2: malformed floating point constant
However, it appears that the numbers are still recognized (and not set to 0 or 1) and then make it through the rest of type-checking/constant evaluation:
package p
const _ = 1 << 1p10
x.go:2: malformed floating point constant
x.go:2: stupid shift: 1024
The fact that we hang in Karatsuba is known and is effectively (indirectly) a duplicate of #11327. But once we set 'p' exponent values to 0, the hang should disappear.
This appears to be fixed. New parser?
$ cat > bug11364.go
package a
var e = 1<<1p10000000<<3
$ go tool compilebug11364.go
go tool compile bug11364.go
bug11364.go:2: syntax error: unexpected p10000000 after top level declaration
and it wastes no time telling me that.
@dr2chase Fixed by you in https://go-review.googlesource.com/c/10450/ I think.