Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The type, precision, and range of clock_t are implementation defined. Both time_t and clock_t are both only defined as "arithmetic types." is specified as an "arithmetic type capable of representing times" as size_t, which is the unsigned result of the sizeof operator. However, how time is encoded within the arithmetic type is unspecified. Therefore, variables of these types should not be modified directly but should only have their values set by functions that understand their underlying representation.

Non-Compliant Code Example

...

Note that this loop may still not exit, as the range of time_t may not be able to represent two times seconds_to_work apart.

Risk Assessment

Changing Using time_t or clock_t typed variables incorrectly can lead to broken logic that could place a program in an infinite loop or cause an expected logic branch to not actually execute.

...

Wiki Markup
\[[Kettlewell 02|AA. C References#Kettlewell 02]\] Section 4.1, "time_t"

Wiki Markup

\[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]] Section 7.23, "Date and time <time.h>"