bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: malloca.c non-top variable declaration


From: Bruno Haible
Subject: Re: malloca.c non-top variable declaration
Date: Wed, 11 Sep 2024 09:56:33 +0200

Hi Simon,

> I noticed a build failure of libidn on an old architecture that doesn't
> permit non-top variable declarations.  How about the patch below?  The
> rest builds fine and passes self-tests on the platform, so presumably
> this was a recently introduced regression in malloca.c related to
> ckd_add.  Thoughts?
> 
> For readability, a 'diff -w' patch is easier to read:
> 
> diff --git a/lib/malloca.c b/lib/malloca.c
> index e75c72df84..6938cdce7a 100644
> --- a/lib/malloca.c
> +++ b/lib/malloca.c
> @@ -69,6 +69,7 @@ mmalloca (size_t n)
>               theoretical platforms where UINTPTR_MAX <= INT_MAX.  */
>            uintptr_t umemplus;
>            ckd_add (&umemplus, umem, sizeof (small_t) + sa_alignment_max - 1);
> +          {
>              idx_t offset = (umemplus - umemplus % (2 * sa_alignment_max)
>                              + sa_alignment_max - umem);
>              void *p = mem + offset;
> @@ -90,6 +91,7 @@ mmalloca (size_t n)
>              return p;
>            }
>          }
> +    }
>    /* Out of memory.  */
>    return NULL;
>  #else

This is an instance of "declaration after statement", which is a feature of C99,
which Gnulib routinely assumes nowadays. We document this since 2017-04-24 [1].

I hope you aren't using -Werror, right?

Does the compilation error go away if you add the 'c99' module to your package's
Gnulib imports?

If not, can you look into the documentation of that platform's compiler and find
compiler flags that turn on maximum C99 compatibility, and make things work
with this?

If not, what platform is this?

Bruno

[1] 
https://www.gnu.org/software/gnulib/manual/html_node/C99-features-assumed.html






reply via email to

[Prev in Thread] Current Thread [Next in Thread]