mpz_get_si: possible undefined behaviour? [Was: Micro-GMP]
Pedro Gimeno
gmpdevel at formauri.es
Thu Dec 6 17:52:18 UTC 2018
Torbjörn Granlund wrote, On 2018-12-05 13:55:
> Let's follow these principles:
>
> 1. We don't need to support every past and present system. E.g., we
> do not support any 16-bit or 8-bit processors, nor do we support the
> once popular 36-bit systems.
>
> 2. We should avoid undefined behaviour which might be relevant only to
> systems we support. E.g. we might want to avoid signed overflow, or
> conversion between negative signed and unsigned integers.
As for (1), I was not suggesting adding support for those systems. I was suggesting to catch any attempt to run (or even compile) GMP in a machine that is not supported due to the sign convention, since we know now that there's code that depends on a specific one already.
As for (2), I don't know how GMP behaves in a non-supported system, as I haven't tried to compile it in one. Perhaps the sign convention is already caught at configure time, or perhaps it should if it isn't already.
I don't even know of any list of supported systems. The manual contains a list of notes for particular systems, but it doesn't specify these are the only ones supported. It also contains a list of ABIs and ISAs but it doesn't seem exhaustive either. There's also a list of CPUs with specific support, but no mention about whether that list is exhaustive, more like the opposite, as it mentions that "CPUs not listed will use generic C code", rather than "CPUs not listed are not supported at all".
Without that information, users can't determine whether GMP is supported in their system. Since they can't, it's reasonable to catch such a problem and report it.
Maybe this discussion should be moved to gmp-bugs.
--
Pedro
More information about the gmp-devel
mailing list