Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot (vkp) v1.0

The type time_t is specified as an "arithmetic type capable of representing times." However, how time is encoded within this arithmetic type by the function time() is unspecified. See unspecified behavior 43 in section J.1 of C99. Because the encoding is unspecified, there is no safe way to manually perform arithmetic on the type, and, as a result, the values should not be modified directly.

Note that POSIX ® ® specifies that the time() function must return a value of type time_t representing time in seconds since the Epoch. Thus, POSIX-conforming applications that aren't intended to be portable to other environments may safely perform arithmetic operations on time_t objects.

...

This rule appears in the C++ Secure Coding Standard as MSC05-CPP. Do not manipulate time_t typed values directly.

...

Bibliography

Wiki Markup
\[[Kettlewell 02|AA. Bibliography#Kettlewell 02]\] Section 4.1, "time_t"
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 7.23, "Date and time <time.h>"

...