[tz] time_t truncation occurrence in tzcode

Đoàn Trần Công Danh congdanhqx at gmail.com
Thu Aug 18 15:22:58 UTC 2022


On 2022-08-18 17:19:07+0200, Jan Engelhardt via tz <tz at iana.org> wrote:
> 
> Due to an update of the Coverity Scan analyzer itself, it has
> identified a new issue in timezone code. In version 2022c (the
> excerpt is copypasted from an own project, so line numbers don't mean
> much), it has flagged:
[...]
> 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;
>               ^^^^^^^^^^^^
> On e.g. x86_64-linux-gnu, time_t is 64 bits (signed) wide, and while
> the specific code path is not executed on that particular platform,
> the warning about a truncation to a 32-bit signed int seems
> justified.

IIUC, CFLAGS="-Dtime_tz=int64_t" is your friends.

-- 
Danh


More information about the tz mailing list