golang/go

fmt: index out of range

dvyukov opened this issue · 1 comments

The following program crashes with a panic:

package main

import "fmt"

func main() {
    fmt.Sprintf("%.80U", 42)
}
panic: runtime error: index out of range

goroutine 1 [running]:
runtime.gopanic(0x4e4740, 0xc20800a1c0)
    src/runtime/panic.go:477 +0x3fe fp=0xc20803f828 sp=0xc20803f7a8
runtime.panicindex()
    src/runtime/panic.go:12 +0x50 fp=0xc20803f850 sp=0xc20803f828
fmt.(*fmt).integer(0xc208052538, 0x2a, 0x10, 0x40e300, 0x51b1d0, 0x10)
    src/fmt/format.go:257 +0x5d0 fp=0xc20803f900 sp=0xc20803f850
fmt.(*pp).fmtUnicode(0xc2080524e0, 0x2a)
    src/fmt/print.go:406 +0xc4 fp=0xc20803f948 sp=0xc20803f900
fmt.(*pp).fmtInt64(0xc2080524e0, 0x2a, 0xc200000055)
    src/fmt/print.go:375 +0x49 fp=0xc20803f980 sp=0xc20803f948
fmt.(*pp).printArg(0xc2080524e0, 0x4c03a0, 0xc20800a420, 0x55, 0x0, 0x0)
    src/fmt/print.go:770 +0xe56 fp=0xc20803fb08 sp=0xc20803f980
fmt.(*pp).doPrintf(0xc2080524e0, 0x5062e0, 0x5, 0xc20803ff60, 0x1, 0x1)
    src/fmt/print.go:1197 +0x217b fp=0xc20803fec0 sp=0xc20803fb08
fmt.Sprintf(0x5062e0, 0x5, 0xc20803ff60, 0x1, 0x1, 0x0, 0x0)
    src/fmt/print.go:203 +0x72 fp=0xc20803ff10 sp=0xc20803fec0
main.main()
    /tmp/fmt.go:6 +0xde fp=0xc20803ff90 sp=0xc20803ff10

on commit d4bb72b

CL https://golang.org/cl/9769 mentions this issue.