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

fmt: mishandling of FALSE in Scanf #2922

Closed
gopherbot opened this issue Feb 8, 2012 · 5 comments
Closed

fmt: mishandling of FALSE in Scanf #2922

gopherbot opened this issue Feb 8, 2012 · 5 comments
Milestone

Comments

@gopherbot
Copy link

by toqueteos:

What steps will reproduce the problem?
1. Reading from stdin a bool value using fmt.Scanf with %t
2. Write FLLSE
3. It works?!

What is the expected output?
Not a boolean value but is evaluated as false.

What do you see instead?
A falsy value.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Linux & Windows

Which revision are you using?  (hg identify)
go version weekly.2011-12-22 11071

Please provide any additional information below.

The error is located here
http://code.google.com/p/go/source/browse/src/pkg/fmt/scan.go#515

That first accept should be s.accept("aA") instead of s.accept("aL")
@rsc
Copy link
Contributor

rsc commented Feb 8, 2012

Comment 1:

I think you have to scan two elements to detect the bug,
because the leading "F" counts as false no matter what.

Labels changed: added priority-go1, go1-must, removed priority-triage.

Owner changed to builder@golang.org.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Feb 9, 2012

Comment 2:

Status changed to WorkingAsIntended.

@rsc
Copy link
Contributor

rsc commented Feb 9, 2012

Comment 3:

I'm pretty sure there's a bug here, as pointed out:
s/aL/aA/.
My comment was about testing for the bug.  I had a hard
time writing a quick test that would break before applying
the fix.  I thought it would be a 1-minute job.

Owner changed to @robpike.

Status changed to Accepted.

@robpike
Copy link
Contributor

robpike commented Feb 9, 2012

Comment 4:

There is a bug in that accept call but as written the program is not a test for it.

@robpike
Copy link
Contributor

robpike commented Feb 9, 2012

Comment 5:

This issue was closed by revision c0e74b6.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned robpike Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants