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.
Created on 2017年07月24日 14:15 by Gabriel Somlo, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| Python-2.7.13-pymem-gcc7.patch | Gabriel Somlo, 2017年07月24日 14:15 | patch to fix gcc7 warnings when calling PyMem_MALLOC macros | ||
| netnsmodule.c | Gabriel Somlo, 2017年07月24日 14:19 | file showing warning emitted with -Wall (error -Werror) | ||
| foo.c | Gabriel Somlo, 2017年07月24日 14:36 | |||
| Messages (6) | |||
|---|---|---|---|
| msg298973 - (view) | Author: Gabriel Somlo (Gabriel Somlo) * | Date: 2017年07月24日 14:15 | |
C programs using PyMem_MALLOC in pymem.h generate a warning when -Wint-in-bool-context is enabled (typically through -Wall). In places where -Werror is enabled (such as RPM build), this causes the build to fail with an error that looks like: ... In file included from /usr/include/python2.7/Python.h:78:0, from netnsmodule.c:16: netnsmodule.c: In function 'netns_nsexecvp': /usr/include/python2.7/pymem.h:97:30: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context] ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) ^ /usr/include/python2.7/pymem.h:75:15: note: in definition of macro 'PyMem_MALLOC' : malloc((n) ? (n) : 1)) ^ netnsmodule.c:61:10: note: in expansion of macro 'PyMem_NEW' argv = PyMem_NEW(char *, argc + 1); ^~~~~~~~~ cc1: all warnings being treated as errors error: command 'gcc' failed with exit status 1 ... I'm attaching a patch that fixes the issue, please consider applying! Thanks, --Gabriel |
|||
| msg298974 - (view) | Author: Gabriel Somlo (Gabriel Somlo) * | Date: 2017年07月24日 14:19 | |
This attachment illustrates how the problem is triggered. The file is part of the CORE network emulator (github.com/coreemu/core). Compile with "gcc -Wall -I/usr/include/python2.7 -c netnsmodule.c". |
|||
| msg298975 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年07月24日 14:25 | |
> /usr/include/python2.7/pymem.h:97:30: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context] I don't understand this error. I would be curious to see the output of the preprocessor. Try maybe to use gcc -E? |
|||
| msg298977 - (view) | Author: Gabriel Somlo (Gabriel Somlo) * | Date: 2017年07月24日 14:36 | |
output of "gcc -E -Wall -I/usr/include/python2.7 -c netnsmodule.c > foo.c" I think gcc7 is a bit more paranoid about whether some expression evaluating to an int can/should in itself be used as a Boolean (i.e., without being compared to 0). |
|||
| msg298978 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2017年07月24日 14:42 | |
> malloc(((argc + 1) * sizeof(char *)) ? ((argc + 1) * sizeof(char *)) : 1)) ) ); Ah ok, the "(n)?" expression is "((argc + 1) * sizeof(char *)) ? " and yes it contains "*". |
|||
| msg313057 - (view) | Author: Petr Viktorin (petr.viktorin) * (Python committer) | Date: 2018年02月28日 11:56 | |
This is a duplicate of https://bugs.python.org/issue31474 which was fixed in https://github.com/python/cpython/pull/3581 It should be included in the next Python 2.7.x release. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:49 | admin | set | github: 75196 |
| 2018年02月28日 17:55:45 | ned.deily | set | status: open -> closed superseder: [2.7] Fix -Wnonnull and -Wint-in-bool-context warnings resolution: duplicate stage: resolved |
| 2018年02月28日 11:56:28 | petr.viktorin | set | nosy:
+ petr.viktorin messages: + msg313057 |
| 2017年07月24日 16:17:25 | cstratak | set | nosy:
+ cstratak |
| 2017年07月24日 14:42:29 | vstinner | set | messages: + msg298978 |
| 2017年07月24日 14:36:47 | Gabriel Somlo | set | files:
+ foo.c messages: + msg298977 |
| 2017年07月24日 14:25:29 | vstinner | set | messages: + msg298975 |
| 2017年07月24日 14:23:52 | vstinner | set | nosy:
+ vstinner |
| 2017年07月24日 14:19:05 | Gabriel Somlo | set | files:
+ netnsmodule.c messages: + msg298974 |
| 2017年07月24日 14:15:36 | Gabriel Somlo | create | |