Large negative pressures

Linus Torvalds torvalds at linux-foundation.org
Wed Aug 7 09:51:28 PDT 2019


On Wed, Aug 7, 2019 at 9:31 AM Linus Torvalds
<torvalds at linux-foundation.org> wrote:
>
> Now, it is possible that while you're doing some intermediate
> calculations, you might end up having temporary values that are bigger
> than int32_t (say, because you're multiplying millimeters by millibars
> and haven't reduced the range in the intermediate values or whatever).

It might be worth trying to just build subsurface with "-ftrapv".

That won't show all overflow problems (*unsigned* overflow in
particular is actually not considered overflow at all in C), but since
this all looks like signed data types, it might cause a nice and
immediate SIGABRT when it hits something that overflows.

Of course, it's quite possible that we have unintentional and harmless
overflows too. There might be code that doesn't really depend on the
overflow, but does a multiply for other reasons (for example,
multiplying a "unsigned char" by 0x01010101 can technically overflow,
because you end up with something that doesn't fit in "int", but the
resulting bit _pattern_ is still exactly what you want).

                Linus

           Linus


More information about the subsurface mailing list