Repository navigation
Warnings on the current main branch #108562
Copy link
Copy link
Closed as not planned
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.13.0a0 (main, Aug 28 2023, 13:54:29) [GCC 12.2.0]
A clear and concise description of the bug:
With
$ # Mon Aug 28 13:44:26 MSK 2023
$ wget https://github.com/python/cpython/archive/refs/heads/main.zip
$ unzip -x main.zip
$ cd cpython-main/
$ ./configure -q && make -sBuild is successful, but I see a bunch of warnings:
In function ‘_io_FileIO_close_impl’,
inlined from ‘_io_FileIO_close’ at ./Modules/_io/clinic/fileio.c.h:34:12:
./Modules/_io/fileio.c:170:9: warning: ‘exc’ may be used uninitialized [-Wmaybe-uninitialized]
170 | _PyErr_ChainExceptions1(exc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Modules/_io/fileio.c: In function ‘_io_FileIO_close’:
./Modules/_io/fileio.c:155:15: note: ‘exc’ was declared here
155 | PyObject *exc;
| ^~~
Note: Deepfreeze may have added some global objects,
so run 'make regen-global-objects' if necessary.
In function ‘word_to_string’,
inlined from ‘coeff_to_string’ at ./Modules/_decimal/libmpdec/io.c:410:13,
inlined from ‘_mpd_to_string’ at ./Modules/_decimal/libmpdec/io.c:611:18:
./Modules/_decimal/libmpdec/io.c:348:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
348 | if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:359:14: note: in expansion of macro ‘EXTRACT_DIGIT’
359 | case 15: EXTRACT_DIGIT(s, x, 100000000000000ULL, dot);
| ^~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:348:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
348 | if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:360:14: note: in expansion of macro ‘EXTRACT_DIGIT’
360 | case 14: EXTRACT_DIGIT(s, x, 10000000000000ULL, dot);
| ^~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:348:40: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
348 | if (s == dot) *s++ = '.'; *s++ = '0' + (char)(x / d); x %= d
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
./Modules/_decimal/libmpdec/io.c:361:14: note: in expansion of macro ‘EXTRACT_DIGIT’
361 | case 13: EXTRACT_DIGIT(s, x, 1000000000000ULL, dot);
| ^~~~~~~~~~~~~
[...]
N.B. second type of warnings (expansions of EXTRACT_DIGIT) seems to be related to the gcc-12. The first I've seen on the Debian Buster (with gcc-10 per default).
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
buildThe build process and cross-buildThe build process and cross-buildtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
sobolevn commentedon Aug 28, 2023
On macos it produces a different result:
skirpichev commentedon Aug 29, 2023
@sobolevn, in my case the build was successful. I did update of the bugreport in case it wasn't clear.
skrah commentedon Jan 29, 2024
The libmpdec warning is a false positive due to
-fno-strict-overflow:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113664
libmpdec very much supports strict overflow, so adding
-fstrict=overflowtoLIBMPDEC_CFLAGSshould fix this.skirpichev commentedon Jan 30, 2024
@skrah, maybe I miss something, but with
--with-strict-overflowI still see warnings:PS:
_io_FileIO_close_impl()from the original report is already fixed.PPS: gcc version was mentioned above:
skrah commentedon Jan 30, 2024
Indeed, that is another false positive (
-Warray-boundsthis time). It is already disabled inmpdecimal-4.0.0.As explained in the linked gcc issue, the exact warning emitted depends on what path the optimizer takes.
The key issue in both cases is that gcc does not like the (correct)
if (s == dot)check.If you compile
--with-strict-overflowand apply this patch, it should work:pythongh-108562: fix compiler warnings for bundled libmpdec in the main
pythongh-108562: fix compiler warnings for bundled libmpdec in the main
skirpichev commentedon Jan 30, 2024
Thanks, that part was backported. See full patch: #114751
gh-108562: Fix compiler warnings for libmpdec (#114751)
encukou commentedon Mar 4, 2024
When this PR was merged, LTO buildbots started failing. See for example: https://buildbot.python.org/all/#/builders/29/builds/5844
erlend-aasland commentedon Mar 4, 2024
Ok, can you revert #114751, @encukou?
8 remaining items
pythongh-108562: turn off false-positive -Wstringop-overflow in word_…
skirpichev commentedon Mar 5, 2024
Alternative fix: #116346
I think so: https://github.com/deadsnakes/python3.13-nightly/actions/runs/8153413773
erlend-aasland commentedon Mar 5, 2024
Thanks for the heads-up, Sergey! Closing as resolved.
skirpichev commentedon Mar 5, 2024
@erlend-aasland, warnings in the main are present. I think this issue isn't solved.
pythongh-108562: Fix compiler warnings for libmpdec (python#114751)
pythongh-108562: Revert enabling -fstrict-overflow for libmpdec (pyth…
pythongh-108562: Fix compiler warnings for libmpdec (python#114751)
pythongh-108562: Revert enabling -fstrict-overflow for libmpdec (pyth…
skirpichev commentedon Oct 6, 2024
@erlend-aasland, this should be fixed if we update bundled mpdecimal to v4. Does it make sense for you?
erlend-aasland commentedon Oct 6, 2024
Aren't we trying to unbundle mpdecimal? :)
skirpichev commentedon Oct 6, 2024
Yes, but Debian people removed mpdecimal.
UPD: ah, no. v4.0.0 doesn't include #116346
vstinner commentedon Oct 7, 2024
@erlend-aasland:
Right, What's New in Python 3.13 says: