Issue 31474: [2.7] Fix -Wnonnull and -Wint-in-bool-context warnings (original) (raw)
GCC 7.1 shows a bunch onf warnings related to -Wnonnull and -Wint-in-bool-context when compiling Python 2.7:
In file included from Include/Python.h:78:0, from Objects/listobject.c:3: Objects/listobject.c: In function ‘list_resize’: Include/pymem.h:110:34: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context] (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) ^ Include/pymem.h:77:21: note: in definition of macro ‘PyMem_REALLOC’ : realloc((p), (n) ? (n) : 1)) ^ Objects/listobject.c:62:9: note: in expansion of macro ‘PyMem_RESIZE’ PyMem_RESIZE(items, PyObject *, new_allocated); ^~~~~~~~~~~~
In file included from Python/formatter_string.c:17:0: Python/../Objects/stringlib/formatter.h: In function ‘format_float_internal’: Python/../Objects/stringlib/formatter.h:576:9: warning: argument 2 null where non-null expected [-Wnonnull] memmove(buf, ^~~~~~~~~~~~ prefix, ~~~~~~~ spec->n_prefix * sizeof(STRINGLIB_CHAR)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from Include/Python.h:38:0, from Python/formatter_string.c:6: /usr/include/string.h:47:14: note: in a call to function ‘memmove’ declared here extern void *memmove (void *__dest, const void *__src, size_t __n)