STINNER Victor <vstin...@python.org> added the comment:
The following C++ code fails to build: --- #ifdef __cplusplus # include <cstdlib> #else # include <stdlib.h> #endif #ifdef __cplusplus extern "C" { #endif typedef struct { int x; int y; char array[]; } mystruct_t; #ifdef __cplusplus } #endif int main() { size_t size = 2; mystruct_t *obj = (mystruct_t *)malloc(sizeof(mystruct_t) - 1 + size); obj->array[0] = 'O'; obj->array[1] = 'K'; free(obj); return 0; } --- Error: --- $ LANG= g++ -pedantic -Werror x.cpp x.c:14:10: error: ISO C++ forbids flexible array member 'array' [-Werror=pedantic] 14 | char array[]; | ^~~~~ cc1plus: all warnings being treated as errors --- ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40120> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com