clang warning about mini-gmp.c when used in Emacs
Niels Möller
nisse at lysator.liu.se
Mon Apr 18 09:19:34 CEST 2022
Vincent Lefevre <vincent at vinc17.net> writes:
>> 1. Is the void cast really needed? Corresponding macros in gmp-impl.h
>> are defined like
>>
>> #if WANT_ASSERT
>> #define ASSERT_CARRY(expr) ASSERT_ALWAYS ((expr) != 0)
>> #define ASSERT_NOCARRY(expr) ASSERT_ALWAYS ((expr) == 0)
>> #else
>> #define ASSERT_CARRY(expr) (expr)
>> #define ASSERT_NOCARRY(expr) (expr)
>> #endif
>
> I'd say that a cast to void is better in order to ensure that
> ASSERT_CARRY(expr) and ASSERT_NOCARRY(expr) have type void
> whether WANT_ASSERT is defined or not, so that type issues
> could be detected more easily.
I see, it would matter for invalid use such as
mp_limb_t cy = ASSERT_NOCARRY(...);
Leaving unchanged for now.
>> 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)
>
> I prefer this patch.
I pushed this version to the repo.
Regards,
/Niels
--
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
More information about the gmp-bugs
mailing list