On Wed, 2007-11-14 at 20:39 +0000, Paul Brook wrote: > > This means that time_t had to be tracked down on varying architectures > > to find the size and there was an assumption made that time_t is 32 bits > > - which isn't true for all targets. The next problem is that if the > > target is 32 bits but the host is 64 bits then there's a sign extension > > problem because (time_t)-1 is used for an error condition. If you don't > > correctly assign assign the 32-bit -1 to a 64-bit type then, rather than > > -1, you get 4294967295. > > Is there any guarantee that time_t is a signed type? The fact that you said > (time_t)-1 suggests it could be an unsigned type. If time_t is an unsigned > type, then casting to a wider value is still wrong. You have to special-case > the error condition. > > In the case of time_t this only becomes relevant after 32-bit time_t wrap in > approx. 99 years time, but I'd expect there are cases where it matters.
time_t is only one example. There are similar problems with the handling of struct target_iovec. There are still other places with similar problems. Yes, special casing can work. There's the possible problem of value truncation when moving between 32 and 64 bits.