Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dlsniper opened this issue May 30, 2016 · 5 comments
Closed

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

dlsniper opened this issue May 30, 2016 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dlsniper
Copy link
Contributor

dlsniper commented May 30, 2016

  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.
@dlsniper
Copy link
Contributor Author

Work on this is a bit more complicated as the initial patch only solves part of the problem, the indexing part still needs a bit more work.

@dlsniper
Copy link
Contributor Author

I have updated the description with the other bad case scenario.

@quentinmit quentinmit added this to the Unplanned milestone Jun 17, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 17, 2016
@quentinmit
Copy link
Contributor

/cc @robpike @valyala based on recent commits

@robpike robpike self-assigned this Jun 17, 2016
@robpike robpike modified the milestones: Go1.8, Unplanned Jun 17, 2016
@valyala
Copy link
Contributor

valyala commented Jun 23, 2016

@dlsniper , @quentinmit , see the CL for this issue - https://go-review.googlesource.com/24391 .

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Aug 29, 2017
@rsc rsc unassigned robpike Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants