Skip to content

cmd/vet: not reporting bad index for the incorrect statement #15884

Closed
@dlsniper

Description

@dlsniper
  1. What version of Go are you using (go version)?
    1.6.2
  2. What operating system and processor architecture are you using (go env)?
    linux/amd64
  3. What did you do?
    The following code:
myWrongFormatVar := "%d %d %#[1]x %#x %2.f %d %2.2f %.f %.3f %[9]*.[2]*[3]f %d %f %#[1]x %#x %[2]d %v % d"
log.Printf(myWrongFormatVar, 1, 2, 3, 4, 5, 6, 7, 8)

produces a BADINDEX at runtime however go vet doesn't catch it. To correct the code one should add a tenth argument to the Printf function and all should be ok.

In fact it should catch if the function has more than 9 other arguments (besides the formatting string) but it doesn't.

The other scenario is this:

log.Printf("%d %d %#[1]x %#x %f %2.f %2.2f %.f %.3f %[3]*.[2]*[1]f %d %d %#[1]x %#x %*[2]d %v % d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)

https://play.golang.org/p/snrXok614V

  1. What did you expect to see?
    An error about the BADINDEX
  2. What did you see instead?
    No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions