clang warning about mini-gmp.c when used in Emacs

Paul Eggert eggert at cs.ucla.edu
Mon Apr 18 09:38:01 CEST 2022


On 4/14/22 22:29, Niels Möller wrote:

> 1. Is the void cast really needed?

Yes, I think so. Various compilers complain if a statement 'E;' has an 
expression E without side effects. The standard way to pacify them is to 
cast E to void. See, for example, 
<https://cs61.seas.harvard.edu/site/2019/Patterns/>.

mini-gmp.c is different from gmp-impl.h, because it's intended to be 
used by lots of downstream projects which may use compilers that 
gmp-impl.h does not use. This may help to explain why it needs casts 
that gmp-impl.h doesn't need.


> Alternative patch:
> 
> --- a/mini-gmp/mini-gmp.c	Tue Feb 15 09:18:40 2022 +0100
> +++ b/mini-gmp/mini-gmp.c	Fri Apr 15 07:20:40 2022 +0200
> @@ -90,6 +90,7 @@ see https://www.gnu.org/licenses/.  */
>   #define gmp_assert_nocarry(x) do { \
>       mp_limb_t __cy = (x);	   \
>       assert (__cy == 0);		   \
> +    (void) __cy;		   \
>     } while (0)

Yes, thanks, that should work too.


More information about the gmp-bugs mailing list