good chemistry is complicated,
and a little bit messy -LW
Re^8: Influencing the Gconvert macroby syphilis (Archbishop)
|on Oct 04, 2020 at 05:09 UTC||Need Help??|
Do you know how to reproduce the warnings when compiling that C script ?
I didn't want to die wondering (even if it killed me), so I eventually came up with this C program that reproduces the warnings:
Build with: gcc -o try.exe try.c -Wformat-overflow
That compilation produces the following noise:
which is essentially the same as the warnings I received when compiling perl.
Apparently, the perl compilation process (with -O2 optimization) determines that the number of digits being requested is 126.
It is then correctly calculated that the number of bytes written will be between 1 and 133 - which allows for the decimal point, a possible leading '-', a possible 'e', and a possible exponent of (maximum) size of 4.
In those warnings, you'll see that the "1 and 133" changes to "2 and 134" - when the terminating NULL byte is included in the count.
I haven't investigated just how the perl source compilation process makes the determination that the digit count has to be 126. It might just be a bug in the -O2 optimization - certainly, no warnings are emitted if the optimization level is reduced to less that -O2.
As I mentioned previously, if the number of digits specified in the "%g" formatting is higher than 91, then the processing switches to a different block of code, so the buffer size of 127 is certainly large enough.
I haven't looked into how or why that change occurs when digits > 91. It's not often that people will request more digits than 91 - so I'm not presently inclined to wade through the whys and wherefores of that processing path. It seems to be working correctly, and IMO that's good enough for now, at least.
Update: Now that I understand how the warning is being created, I think it should be fairly simple to amend the perl source so that this warning is eliminated.