2 minor issues on Windows

Torbjörn Granlund tg at gmplib.org
Sun Mar 13 00:06:42 CET 2022


  There is some sort of sick competition between certain compilers to have
  the most warnings for valid C.  I don't think we should play their game,
  and as a result obfuscate the GMP sources.

Incidantally, arithmetic on unsigned types is well-defined.  Unlike that
of signed types.

Should not these compilers warn about *every* arithmetic operation on
signed integers?  Certainly, it should warn about signed negation,
unless it can prove the negated value is not INT_MIN, as -INT_MIN is
undefined in two's complement representation...

int
foo (int a, int b)
{
  return a + b - 1;
}

$ clank foo.c
warning: signed addition might overflow and yield undefined results
warning: signed subtraction might overflow and yield undefined results

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-bugs mailing list