On Wed, 24 Apr 2024 at 11:13, Dirk Hohndel via subsurface
<[email protected]> wrote:
>
> Those with better skills in interpreting error messages... what am I missing?

I think the line numbers are wrong, probably because of inlining etc.

The real issue is _probably_ on line 525:

        snprintf(fl, 13, "ANS%d.TXT", filenumber);

where the compiler things that the 13 byte buffer is not enough for
some integers (ie "%d" could be "-2147483648", which is 11 characters
just there). Thus the "0..12" thing.

And yes, we do that clamping to 0..9999, but I suspect the compiler
can't quite follow it, and doesn't quite figure out that the max is
3+4+4+1.

And it probably all depends on compiler version and just random
phase-of-the-moon things.

But my guess is that you should change the magic "13" to be something
bigger, preferably something that is safe for any integer so that the
compiler doesn't have to understand the clamping logic.

Alternatively, make it easier for the compiler to understand the
clamping: maybe make 'filenumber' be unsigned (and make the "%d" be
"%u), and then just do

        if (filenumber > UEMIS_MAX_FILES)
                filenumber = 0;

which is a *lot* easier for a compiler to understand than the
currently "conditional signed modulus" operation it does.

              Linus
_______________________________________________
subsurface mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to