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