[tz] zic.c - compilation broken on gcc 4.8.3 after commit e5b2ee634c7151484c06740ea2c8a4d4a75409b6

Иванов Игорь i.ivanov at dssl.ru
Fri Oct 28 14:43:51 UTC 2022


Good time of day.

This commit breaks compilation at least on GCC 4.8.3:

    commit e5b2ee634c7151484c06740ea2c8a4d4a75409b6
    Author: Paul Eggert <eggert at cs.ucla.edu>
    Date:   Thu Oct 20 11:41:27 2022 -0700
        Use C23 __has_include if available

It causes this compilation error:

    zic.c: In function ‘main’:
    zic.c:813:16: error: ‘optarg’ undeclared (first use in this function)
        if (strcmp(optarg, "slim") == 0) {
                    ^
    zic.c:906:6: error: ‘optind’ undeclared (first use in this function)
    if (optind == argc - 1 && strcmp(argv[optind], "=") == 0)
        ^

Specifically hunks like this are problematic:

    @@ -55,8 +63,8 @@
     #endif

     #ifndef HAVE_GETTEXT
    -# define HAVE_GETTEXT 0
    -#endif /* !defined HAVE_GETTEXT */
    +# define HAVE_GETTEXT HAS_INCLUDE(<libintl.h>, false)
    +#endif

     #ifndef HAVE_INCOMPATIBLE_CTIME_R
     # define HAVE_INCOMPATIBLE_CTIME_R 0

The culprit is the replacement 0 -> false and 1 -> true. Apparently it breaks #if preprocessor logic in older compilers somewhere downstream - what was #if 1 becomes #if true, which GCC treats as "false" and falls into #else branch.

"Restoring" false and true back to 0 and 1 seems to fix the issue.

Best regards,
Igor Ivanov,
Software engineer at DSSL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mm.icann.org/pipermail/tz/attachments/20221028/b2e54213/attachment.html>


More information about the tz mailing list