null

On Sat, Dec 20, 2025 at 10:41 PM Paul Eggert via tz <[email protected]> wrote:

> * private.h (ATTRIBUTE_PURE_114833_HACK): New macro.
> * zdump.c (sumsize):
> * zic.c (size_sum, size_product, align_to, oadd, tadd):
> Use it.
> ---
>  private.h |  6 ++++++
>  zdump.c   |  3 ++-
>  zic.c     | 27 ++++++++++++++++++---------
>  3 files changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/private.h b/private.h
> index 50d6a52a..55a8d548 100644
> --- a/private.h
> +++ b/private.h
> @@ -642,6 +642,12 @@ typedef unsigned long uintmax_t;
>  #else
>  # define ATTRIBUTE_PURE_114833 /* empty */
>  #endif
> +/* GCC_LINT hack to pacify GCC bug 114833 even though the attribute is
> +   not strictly correct, as the function might not return whereas pure
> +   functions are supposed to return exactly once.  This hack is not
> +   known to generate wrong code for tzcode on any platform.
> +   Remove this macro and its uses when the bug is fixed in a GCC
> release.  */
> +#define ATTRIBUTE_PURE_114833_HACK ATTRIBUTE_PURE_114833
>
>  #if (__STDC_VERSION__ < 199901 && !defined restrict \
>       && (PORT_TO_C89 || defined _MSC_VER))
> diff --git a/zdump.c b/zdump.c
> index 4860e3bc..c7812eae 100644
> --- a/zdump.c
> +++ b/zdump.c
> @@ -123,7 +123,8 @@ size_overflow(void)
>
>  /* Return A + B, exiting if the result would overflow either ptrdiff_t
>     or size_t.  A and B are both nonnegative.  */
> -ATTRIBUTE_PURE_114833 static ptrdiff_t
> +ATTRIBUTE_PURE_114833_HACK
> +static ptrdiff_t
>  sumsize(ptrdiff_t a, ptrdiff_t b)
>  {
>  #ifdef ckd_add
> diff --git a/zic.c b/zic.c
> index 12854c43..a7c70895 100644
> --- a/zic.c
> +++ b/zic.c
> @@ -555,7 +555,8 @@ size_overflow(void)
>    memory_exhausted(_("size overflow"));
>  }
>
> -ATTRIBUTE_PURE_114833 static ptrdiff_t
> +ATTRIBUTE_PURE_114833_HACK
> +static ptrdiff_t
>  size_sum(size_t a, size_t b)
>  {
>  #ifdef ckd_add
> @@ -569,7 +570,8 @@ size_sum(size_t a, size_t b)
>    size_overflow();
>  }
>
> -ATTRIBUTE_PURE_114833 static ptrdiff_t
> +ATTRIBUTE_PURE_114833_HACK
> +static ptrdiff_t
>  size_product(ptrdiff_t nitems, ptrdiff_t itemsize)
>  {
>  #ifdef ckd_mul
> @@ -584,7 +586,8 @@ size_product(ptrdiff_t nitems, ptrdiff_t itemsize)
>    size_overflow();
>  }
>
> -ATTRIBUTE_PURE_114833 static ptrdiff_t
> +ATTRIBUTE_PURE_114833_HACK
> +static ptrdiff_t
>  align_to(ptrdiff_t size, ptrdiff_t alignment)
>  {
>    ptrdiff_t lo_bits = alignment - 1, sum = size_sum(size, lo_bits);
> @@ -1691,7 +1694,8 @@ relname(char const *target, char const *linkname)
>  /* Return true if A and B must have the same parent dir if A and B exist.
>     Return false if this is not necessarily true (though it might be true).
>     Keep it simple, and do not inspect the file system.  */
> -ATTRIBUTE_PURE_114833 static bool
> +ATTRIBUTE_PURE_114833
> +static bool
>  same_parent_dirs(char const *a, char const *b)
>  {
>    for (; *a == *b; a++, b++)
> @@ -3897,7 +3901,8 @@ lowerit(char a)
>  }
>
>  /* case-insensitive equality */
> -ATTRIBUTE_PURE_114833 static bool
> +ATTRIBUTE_PURE_114833
> +static bool
>  ciequal(register const char *ap, register const char *bp)
>  {
>         while (lowerit(*ap) == lowerit(*bp++))
> @@ -3906,7 +3911,8 @@ ciequal(register const char *ap, register const char
> *bp)
>         return false;
>  }
>
> -ATTRIBUTE_PURE_114833 static bool
> +ATTRIBUTE_PURE_114833
> +static bool
>  itsabbr(register const char *abbr, register const char *word)
>  {
>         if (lowerit(*abbr) != lowerit(*word))
> @@ -3922,7 +3928,8 @@ itsabbr(register const char *abbr, register const
> char *word)
>
>  /* Return true if ABBR is an initial prefix of WORD, ignoring ASCII
> case.  */
>
> -ATTRIBUTE_PURE_114833 static bool
> +ATTRIBUTE_PURE_114833
> +static bool
>  ciprefix(char const *abbr, char const *word)
>  {
>    do
> @@ -4032,7 +4039,8 @@ time_overflow(void)
>    exit(EXIT_FAILURE);
>  }
>
> -ATTRIBUTE_PURE_114833 static zic_t
> +ATTRIBUTE_PURE_114833_HACK
> +static zic_t
>  oadd(zic_t t1, zic_t t2)
>  {
>  #ifdef ckd_add
> @@ -4046,7 +4054,8 @@ oadd(zic_t t1, zic_t t2)
>    time_overflow();
>  }
>
> -ATTRIBUTE_PURE_114833 static zic_t
> +ATTRIBUTE_PURE_114833_HACK
> +static zic_t
>  tadd(zic_t t1, zic_t t2)
>  {
>  #ifdef ckd_add
> --
> 2.51.0
>
>

Reply via email to