[tz] [tzcode 2022g] Undeclared variable/typo in zdump.c

Paul Eggert eggert at cs.ucla.edu
Wed Mar 22 18:18:20 UTC 2023


On 2023-03-22 02:55, panic wrote:

> I contact you directly, because access to the mailing list is currently
> very limited (new subscriber).

Thanks, I'll include a copy of your email below, so that other 
subscribers of the tz mailing list can see it.

> I try to cross-compile tzcode 2022g from GNU/Linux (NixOS) to Windows
> using GCC 12.2.0 (x86_64-w64-mingw32) and get this compilation error:
> 
>> In file included from zdump.c:14:
>> zdump.c: In function 'zdump_tzalloc':
>> zdump.c:264:38: error: 'initial_envptrs' undeclared (first use in this function); did you mean 'initial_nenvptrs'?
>>    264 |       if (ckd_add(&initial_nenvptrs, initial_envptrs, 1)
>>        |                                      ^~~~~~~~~~~~~~~
>> private.h:414:51: note: in definition of macro 'ckd_add'
>>    414 | #  define ckd_add(r, a, b) __builtin_add_overflow(a, b, r)
>>        |                                                   ^
>> zdump.c:264:38: note: each undeclared identifier is reported only once for each function it appears in
>>    264 |       if (ckd_add(&initial_nenvptrs, initial_envptrs, 1)
>>        |                                      ^~~~~~~~~~~~~~~
>> private.h:414:51: note: in definition of macro 'ckd_add'
>>    414 | #  define ckd_add(r, a, b) __builtin_add_overflow(a, b, r)
>>        |                                                   ^
>> make: *** [<builtin>: zdump.o] Error 1
> 
> I suspect `initial_envptrs` is a typo and should be `initial_nenvptrs`,
> as the former does not occur anywhere else.
> 
> Building natively for Linux works just fine. For cross-compilation, I
> build additionally with
> 
>> "CFLAGS+=-DHAVE_DIRECT_H"
>> "CFLAGS+=-DHAVE_SETENV=0"
>> "CFLAGS+=-DHAVE_SYMLINK=0"
>> "CFLAGS+=-DRESERVE_STD_EXT_IDS"
> 
> `-DHAVE_SETENV=0` selects the alternative path in `zdump_tzalloc` and in
> combination with a recent GCC triggers error. Normally, `HAVE_SETENV=1`
> and the code path is not compiled. Maybe the combination of a recent GCC
> and
> `-DHAVE_SETENV=0` is rarely tested and therefore the typo was not
> discovered before.
> 
> Cheers,
> -- panic


Thanks for the bug report. I've never built with that particular 
combination, and you exposed a couple of typos. I reproduced the problem 
artificially on GNU/Linux by building with "make 
CFLAGS='-DHAVE_SETENV=0'" and installed the attached patches. This fix 
should appear in the next release, which should be soon.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Port-to-C23-setenv-localtime_rz.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <https://mm.icann.org/pipermail/tz/attachments/20230322/0b753f46/0001-Port-to-C23-setenv-localtime_rz.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-NEWS-Document-previous-change.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <https://mm.icann.org/pipermail/tz/attachments/20230322/0b753f46/0002-NEWS-Document-previous-change.patch>


More information about the tz mailing list