coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] expr: fix build failure with -Werror=suggest-attribute=mallo


From: Pádraig Brady
Subject: Re: [PATCH] expr: fix build failure with -Werror=suggest-attribute=malloc
Date: Sun, 24 Jun 2018 20:11:14 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 24/06/18 20:00, Carlos Santos wrote:
> Add attribute 'malloc' to mpz_get_str to prevent a compilation error:
> 
>   src/expr.c:117:1: error: function might be candidate for attribute
>     'malloc' if it is known to return normally
>       [-Werror=suggest-attribute=malloc]
>    mpz_get_str (char const *str, int base, mpz_t z)
>    ^~~~~~~~~~~
>   cc1: all warnings being treated as errors
> ---
>  src/expr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/expr.c b/src/expr.c
> index f4dbf1792..94eb9e78f 100644
> --- a/src/expr.c
> +++ b/src/expr.c
> @@ -113,7 +113,7 @@ mpz_tdiv_r (mpz_t r, mpz_t a0, mpz_t b0)
>    /* Some x86-style hosts raise an exception for INT_MIN % -1.  */
>    r[0] = a < - INTMAX_MAX && b == -1 ? 0 : a % b;
>  }
> -static char *
> +static char * _GL_ATTRIBUTE_MALLOC
>  mpz_get_str (char const *str, int base, mpz_t z)
>  {
>    (void) str; (void) base;
> 

This looks good.
Though there was a recent report of GCC 9 being clean wrt warnings.
What compiler (version) gave this warning?

thanks,
Pádraig



reply via email to

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