[issue40120] Undefined C behavior going beyond end of struct via a char[1].

Sam Gross report at bugs.python.org
Tue Mar 31 12:46:56 EDT 2020


Sam Gross <colesbury at gmail.com> added the comment:

It may be worth considering C-API extensions written in C++. Flexible array members are not part of the C++ standard, although GCC, Clang, and MSVC support them as an extension. GCC and Clang will issue warnings with `-Wpedantic` and MSVC will issue warnings with `/Wall`. Currently, C++ code that includes `<Python.h>` is warning-free in GCC (g++) even with `-Wpedantic`. That won't be true after this change, unless Py_LIMITED_API is defined.

Note that GCC also explicitly supports trailing one-element arrays (the current pattern) as an extension. https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

----------
nosy: +colesbury

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40120>
_______________________________________


More information about the Python-bugs-list mailing list