[tz] time_t truncation occurrence in tzcode

Paul Eggert eggert at cs.ucla.edu
Thu Aug 18 15:34:48 UTC 2022


On 8/18/22 08:19, Jan Engelhardt via tz wrote:
> 1769        if (!TYPE_SIGNED(time_t) && y < TM_YEAR_BASE) {
>      CID 1491244 (#1 of 1): Use of 32-bit time_t (Y2K38_SAFETY)
> 1. store_truncates_time_t: A time_t value is stored in an integer
> with too few bits to accommodate it. The expression y is cast to int.
> 1770          int signed_y = y;
>                ^^^^^^^^^^^^

The Coverity warning is clearly a false alarm. y is a time_t, so if 
time_t is unsigned and y < TM_YEAR_BASE, then 0≤
y<1900, and therefore assigning y to an int cannot possibly truncate y's 
value.

If Coverity formerly didn't issue a false alarm here, it's a regression 
in Coverity. Perhaps you could file a bug with the Coverity maintainers. 
You might also mention a terminology glitch: the false alarm says "y is 
cast to int" but there's no cast in that line.


More information about the tz mailing list