On 2024-05-03 17:14, Collin Funk wrote:
Also about this comment in intprops-internal.h:
/* This include file assumes that signed types are two's complement without
padding bits; the above macros have undefined behavior otherwise.
If this is a problem for you, please let us know how to fix it for your
host.
This assumption is tested by the intprops-tests module. */
If you want to check this at compile time I think this should work:
Not quite, because it doesn't check for padding bits. Also, your code
assumes that preprocessor arithmetic works the same as runtime
arithmetic. Although C23 guarantees this (because it guarantees two's
complement) I don't think C17 and earlier do. If memory serves, they
even allow mixed-runtime systems, where arithmetic is sometimes ones'
complement and sometimes two's. (Almost nobody cares about this
theoretical possibility of course, which is why the Gnulib manual says
not to worry about it.)