This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Compile warnings in _pickle.c
Type: compile error Stage: resolved
Components: Extension Modules Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-09-27 05:34 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue25245_1.patch serhiy.storchaka, 2015-09-27 06:33 Variant 1 review
issue25245_2.patch serhiy.storchaka, 2015-09-27 06:34 Variant 2 review
Messages (6)
msg251683 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-27 05:34
Changeset 88d98f6c2d7d causes compile warnings in Modules/_pickle.c.

/home/serhiy/py/cpython/Modules/_pickle.c: In function ‘load_counted_long’:
/home/serhiy/py/cpython/Modules/_pickle.c:4752:15: warning: ‘pdata’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         value = _PyLong_FromByteArray((unsigned char *)pdata, (size_t)size,
               ^
/home/serhiy/py/cpython/Modules/_pickle.c: In function ‘load’:
/home/serhiy/py/cpython/Modules/_pickle.c:5534:24: warning: ‘s’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     idx = Py_CHARMASK(s[0]);
                        ^
/home/serhiy/py/cpython/Modules/_pickle.c:5529:11: note: ‘s’ was declared here
     char *s;
           ^
/home/serhiy/py/cpython/Modules/_pickle.c:4800:7: warning: ‘s’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     x = _PyFloat_Unpack8((unsigned char *)s, 0);
       ^
/home/serhiy/py/cpython/Modules/_pickle.c:4795:11: note: ‘s’ was declared here
     char *s;
           ^
msg251684 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-27 06:33
Here are two alternative solutions.
msg251686 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-09-27 07:36
Why not just initially set *s to NULL in _Unpickler_Read?
msg251687 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-09-27 07:51
> Why not just initially set *s to NULL in _Unpickler_Read?

It would be the third variant.

The fourth variant is to change the signature of _Unpickler_Read() and return 
char * (NULL on error). All these variants work, I examined them.
msg251688 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-09-27 08:16
New changeset f0dcf7599517 by Benjamin Peterson in branch '3.4':
initialize return value to NULL to avoid compiler compliants (closes #25245)
https://hg.python.org/cpython/rev/f0dcf7599517

New changeset ef3b833b98c2 by Benjamin Peterson in branch '3.5':
merge 3.4 (#25245)
https://hg.python.org/cpython/rev/ef3b833b98c2

New changeset 4d23598f1428 by Benjamin Peterson in branch 'default':
merge 3.5 (#25245)
https://hg.python.org/cpython/rev/4d23598f1428
msg251689 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2015-09-27 08:17
Okay, I think it might make more sense for |s| to be a return value, but that change probably isn't appropriate for bugfix releases.
History
Date User Action Args
2022-04-11 14:58:21adminsetgithub: 69432
2015-09-27 08:17:17benjamin.petersonsetmessages: + msg251689
2015-09-27 08:16:30python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg251688

resolution: fixed
stage: patch review -> resolved
2015-09-27 07:51:23serhiy.storchakasetmessages: + msg251687
2015-09-27 07:36:21benjamin.petersonsetmessages: + msg251686
2015-09-27 06:34:11serhiy.storchakasetfiles: + issue25245_2.patch
2015-09-27 06:33:36serhiy.storchakasetfiles: + issue25245_1.patch
keywords: + patch
messages: + msg251684

stage: patch review
2015-09-27 05:34:59serhiy.storchakacreate