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

time: == on time.Time values compiles but doesn't work #8754

Closed
robpike opened this issue Sep 16, 2014 · 3 comments
Closed

time: == on time.Time values compiles but doesn't work #8754

robpike opened this issue Sep 16, 2014 · 3 comments
Milestone

Comments

@robpike
Copy link
Contributor

robpike commented Sep 16, 2014

When we permitted == on structs in an earlier release of Go, we accidentally made
time.Time values comparable this way. However, because time.Time values contain a
*Location pointer, it's possible (and easy) to have two time.Times represent the same
instant, even in the same time zone, yet compare unequal. This is a serious bug, as it
enables subtle bugs if a time.Time is used as a key in a map or database.

We need to find a way either to to break == statically or make it work dynamically.

Too late for 1.4, as the issue is subtle. Marking for 1.5.
@robpike
Copy link
Contributor Author

robpike commented Sep 16, 2014

Comment 1:

Labels changed: added repo-main.

@dsymonds
Copy link
Contributor

Comment 2:

I don't this can be changed. With sufficient care one can construct time.Time values
that *are* sensibly comparable with ==, and use them as map keys or whatever. We'd be
breaking such code.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
@robpike
Copy link
Contributor Author

robpike commented Apr 28, 2015

Closing; the comment is all we can reasonably without significantly breaking code.

@robpike robpike closed this as completed Apr 28, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

5 participants