difftime can throw exceptions

difftime can signal an inexact conversion when converting to double,
so it should not be marked as pure or nothrow (BZ 31808).

Although we could do something more complicated, in which difftime is
plain on modern platforms but const and nothrow on obsolescent
platforms with 32-bit time_t, it hardly seems worth the trouble.
difftime is used so rarely that it's not worth taking pains to
optimize calls to it on obsolescent platforms.

Reviewed-by: DJ Delorie <dj@redhat.com>
This commit is contained in:
Paul Eggert 2024-05-28 10:07:47 -07:00
parent 127fc56152
commit cafef3eb21

View File

@ -76,8 +76,7 @@ extern clock_t clock (void) __THROW;
extern time_t time (time_t *__timer) __THROW; extern time_t time (time_t *__timer) __THROW;
/* Return the difference between TIME1 and TIME0. */ /* Return the difference between TIME1 and TIME0. */
extern double difftime (time_t __time1, time_t __time0) extern double difftime (time_t __time1, time_t __time0);
__THROW __attribute_pure__;
/* Return the `time_t' representation of TP and normalize TP. */ /* Return the `time_t' representation of TP and normalize TP. */
extern time_t mktime (struct tm *__tp) __THROW; extern time_t mktime (struct tm *__tp) __THROW;
@ -85,7 +84,7 @@ extern time_t mktime (struct tm *__tp) __THROW;
# ifdef __REDIRECT_NTH # ifdef __REDIRECT_NTH
extern time_t __REDIRECT_NTH (time, (time_t *__timer), __time64); extern time_t __REDIRECT_NTH (time, (time_t *__timer), __time64);
extern double __REDIRECT_NTH (difftime, (time_t __time1, time_t __time0), extern double __REDIRECT_NTH (difftime, (time_t __time1, time_t __time0),
__difftime64) __attribute_pure__; __difftime64);
extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64); extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
# else # else
# define time __time64 # define time __time64