On 2025-09-23 17:23, Robert Elz wrote:

The "one of two" is just that some return a pointer to
a struct tm, and others to a char [].
I don't see that as a plausible reading. The text says "one of two static objects", not "a pointer of one of two types". There are two static objects, one for localtime/gmtime and the other for asctime/ctime, and that's pretty clear from the wording.

And I'm not the only person to read the standards this way. See, for example, <https://codebrowser.dev/glibc/glibc/time/localtime.c.html>, which says "C89 says that localtime and gmtime return the same pointer." Wording to this effect has been in glibc since 1995.

Although later C standards relax this (and I'll have more to say about that in a later email), POSIX.1-2024 still has the C89 requirement.

As you probably know, the standards did not invent this requirement. In 7th edition Unix, localtime and gmtime calls always returned the same pointer - because localtime called gmtime, scribbled on the object pointed to by gmtime's result, and then returned whatever pointer gmtime returned.

Reply via email to