Skip to content

time: Reminder to change Time.nsec from uintptr to int32 #7664

@gopherbot

Description

@gopherbot

by Matthew.Ickstadt:

I noticed a TODO in time.go which was still present in 1afdecdd77c1:

type Time struct {
        // sec gives the number of seconds elapsed since
        // January 1, year 1 00:00:00 UTC.
        sec int64

        // nsec specifies a non-negative nanosecond
        // offset within the second named by Seconds.
        // It must be in the range [0, 999999999].
        //
        // It is declared as uintptr instead of int32 or uint32
        // to avoid garbage collector aliasing in the case where
        // on a 64-bit system the int32 or uint32 field is written
        // over the low half of a pointer, creating another pointer.
==>     // TODO(rsc): When the garbage collector is completely
==>     // precise, change back to int32.
==>     nsec uintptr

        // loc specifies the Location that should be used to
        // determine the minute, hour, month, day, and year
        // that correspond to this Time.
        // Only the zero Time has a nil Location.
        // In that case it is interpreted to mean UTC.
        loc *Location
}

Now that the GC completely precise, I'm assuming this minor change can be made.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions