[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral
From: |
Bruno Haible |
Subject: |
Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral |
Date: |
Sun, 10 Oct 2010 23:15:34 +0200 |
User-agent: |
KMail/1.9.9 |
Paul Eggert wrote:
> * lib/time.in.h (struct __time_t_must_be_integral): Rewrite
> 2 * ((time_t) 1 / 2 == 0) - 1 to (time_t) 1; this suffices to
> verify that time_t cannot be floating.
I disagree that this is enough. The C standard says that a cast to floating-
point types cannot be portably used in integer constant expressions. But a
compiler is free to support this, as an extension. _If_ a compiler supports
it as an extension, then
2 * ((time_t) 1 / 2 == 0) - 1 will evaluate to -1
(time_t) 0.5 == 0 ? 1 : -1 will evaluate to -1
but the expression you put in:
(time_t) 1 will evaluate to 1
Bruno
- Re: [coreutils] [PATCH 2/2] stat: print timestamps to full resolution, Eric Blake, 2010/10/08
- Re: [coreutils] [PATCH 2/2] stat: print timestamps to full resolution, Jim Meyering, 2010/10/08
- [PATCH] time: enforce recent POSIX ruling that time_t is integral, Eric Blake, 2010/10/08
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/09
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/09
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Bruno Haible, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral,
Bruno Haible <=
- Re: [PATCH] time: enforce recent POSIX ruling that time_t is integral, Paul Eggert, 2010/10/10
- [PATCH] Fix mismatched parens in previous commit, Gary V. Vaughan, 2010/10/11
- Re: [PATCH] Fix mismatched parens in previous commit, Jim Meyering, 2010/10/11
- Re: [PATCH] Fix mismatched parens in previous commit, Gary V. Vaughan, 2010/10/11
- Re: [PATCH] Fix mismatched parens in previous commit, Paul Eggert, 2010/10/11
- [PATCH] rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1], Paul Eggert, 2010/10/10
- Re: [PATCH] rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1], Bruno Haible, 2010/10/10
- Re: [PATCH] rewrite int foo[2*X-1] to verify(X) or to int foo[X?1:-1], Paul Eggert, 2010/10/10