time: In time.Unix, an underflow occurs when you put a large negative value in the seconds area #64514
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.21.4 linux/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
As follows, create a time object by entering the maximum and minimum values of int64 and output it as a string.
What did you expect to see?
I expected max to be a very large time value, and min to be a negative time value similar to max.
What did you see instead?
In the case of the maximum value, very large time values are output as positive numbers, as intended.
However, for the minimum value, a positive number is output, even though it should be a negative value.
When I tested it myself, the minimum value that was actually output as a negative number was
time.Unix(math.MinInt64+8139423736, 0)
.An underflow occurs starting from
time.Unix(math.MinInt64+8139423735, 0)
.However, it doesn't seem to be specified in the document.
Is this behavior by design? Or is this a bug or undefined behavior?
The text was updated successfully, but these errors were encountered: