(e-mail address removed) said:
No. I suppose I'll have to concede that it's a reason - but it's
inexcusable, and therefore not an excuse.
If it's a reason, then its a lame reason, because that reason assumes
all implementors use 32 bit integers for time_t and that they are
coded the same.
Here is what the standard says:
7.23 Date and time <time.h>
7.23.1 Components of time
1 The header <time.h> defines two macros, and declares several types
and functions for manipulating time. Many functions deal with a
calendar time that represents the current date (according to the
Gregorian calendar) and time. Some functions deal with local time,
which is the calendar time expressed for some specific time zone, and
with Daylight Saving Time, which is a temporary change in the
algorithm for determining local time. The local time zone and Daylight
Saving Time are implementation-defined.
2 The macros defined are NULL (described in 7.17); and
CLOCKS_PER_SEC
which expands to an expression with type clock_t (described below)
that is the number per second of the value returned by the clock
function.
3 The types declared are size_t (described in 7.17);
clock_t
and
time_t
which are arithmetic types capable of representing times; and
struct tm
which holds the components of a calendar time, called the broken-down
time.
4 The range and precision of times representable in clock_t and time_t
are implementation-defined. The tm structure shall contain at least
the following members, in any order. The semantics of the members and
their normal ranges are expressed in the comments.274)
int tm_sec; // seconds after the minute — [0, 60]
int tm_min; // minutes after the hour — [0, 59]
int tm_hour; // hours since midnight — [0, 23]
int tm_mday; // day of the month — [1, 31]
int tm_mon; // months since January — [0, 11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday — [0, 6]
int tm_yday; // days since January 1 — [0, 365]
int tm_isdst; // Daylight Saving Time flag
The value of tm_isdst is positive if Daylight Saving Time is in
effect, zero if Daylight Saving Time is not in effect, and negative if
the information is not available.
Footnote 274) The range [0, 60] for tm_sec allows for a positive leap
second.
All that the standard says is that time_t is an arithmetic type
capable of representing times. Hence, we cannot make any assumptions
about its size or nature other than what the compiler tells us with
sizeof(time_t).
It would also be a mistake to assume that even between iterations of a
compiler that clock_t, size_t, and time_t are the same size (just as
assuming that pointers are the same size with different compiler
versions is an error).
While it would be very nice for the compiler vendor to provide a
helper function for conversion of old types to new types, if our code
exhibits problems because we assume that the sizes of things never
changed that shows a distinct lack of foresight in our case.
Would we feel sorry for someone who's code broke because they assumed
all pointers fit into 32 bits? (Well, maybe, if we once assumed that
integers were always between -32768 and + 32767)
;-)
Anyway, assumptions about the size and content of a time_t, a size_t,
a clock_t, or the width of a function or data pointer are bad
assumptions. And if they prevent the upgrade of the compiler's time
types to something that won't cause devatating errors in the near
future then the assumptions are whatever is worse than bad. Evil
{calamitous?}, perhaps?