[Python-Dev] Fix strncpy warning with gcc 8 (#5840) (original) (raw)
Eric V. Smith eric at trueblade.com
Tue Mar 6 14:45:59 EST 2018
- Previous message (by thread): [Python-Dev] Fix strncpy warning with gcc 8 (#5840)
- Next message (by thread): [Python-Dev] Backward incompatible change about docstring AST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3/6/2018 6:52 AM, Serhiy Storchaka wrote:
06.03.18 12:34, Xiang Zhang пише:
https://github.com/python/cpython/commit/efd2bac1564f8141a4eab1bf8779b412974b8d69
commit: efd2bac1564f8141a4eab1bf8779b412974b8d69 branch: master author: Siddhesh Poyarekar <siddhesh.poyarekar at gmail.com> committer: Xiang Zhang <angwerzx at 126.com> date: 2018-03-06T18:34:35+08:00 summary: Fix strncpy warning with gcc 8 (#5840) The length in strncpy is one char too short and as a result it leads to a build warning with gcc 8. Comment out the strncpy since the interpreter aborts immediately after anyway. files: M Python/pystrtod.c diff --git a/Python/pystrtod.c b/Python/pystrtod.c index 9bf936386210..601f7c691edf 100644 --- a/Python/pystrtod.c +++ b/Python/pystrtod.c @@ -1060,8 +1060,8 @@ formatfloatshort(double d, char formatcode, else { /* shouldn't get here: Gay's code should always return something starting with a digit, an 'I', or 'N' */ - strncpy(p, "ERR", 3); - /* p += 3; */ + /* strncpy(p, "ERR", 3); + p += 3; */ PyUNREACHABLE(); } goto exit; I think this code was added for purpose. In the case of programming error we could get meaningful value in post-mortal debugging. But after replacing assert(0) with PyUNREACHABLE this perhaps lost a sense. If this code is no longer needed it is better to remove it than keeping an obscure comment. What are your thoughts @warsaw and @ericvsmith? PyUNREACHABLE was added in issue31338 by Barry. The original code was added in issue1580 by Eric Smith (maybe it was copied from other place).
Mark Dickinson and/or I wrote that. I agree that leaving the two commented out lines is confusing. I suggest deleting them, and of course leave the comment about Gay's code.
Eric
- Previous message (by thread): [Python-Dev] Fix strncpy warning with gcc 8 (#5840)
- Next message (by thread): [Python-Dev] Backward incompatible change about docstring AST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]