PEP-7 update to allow C99 flexible array member syntax

I need this to solve a C undefined behavior issue in the language approved manner.

https://en.wikipedia.org/wiki/Flexible_array_member describes the language feature better than I can.

Why? See https://bugs.python.org/issue40120 and code using it in https://github.com/python/peps/pull/1349.

What does it allow us to change? Instead of ending variable length structures with char spam[1]; as we do today for PyBytesObject and unicode’s internal struct encoding_map, end them with char spam[]; (and adjust any size computations when relevant).

So far testing (CI and all the buildbots it throws at it) have not turned up any compilers with issues. It has been around for 21 years. I’d be surprised to find any that balk at it.

Any objections?

2 Likes

AFAIK this syntax is incorrect in C++.

2 Likes