This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/69550] Need a way to disable "flexible array member in an otherwise empty struct" error on GCC 6


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69550

--- Comment #15 from Martin Sebor <msebor at gcc dot gnu.org> ---
I did try to match the C front end but there are a few cases where I made C++
slightly stricter based on Jason's input about the direction C++ is heading
with respect to aliasing rules.  This is one of those cases (there's a test for
it in the test suite).

In addition, besides maintaining the property that every complete type has a
non-zero size, the C rationale for requiring structs containing a flexible
array to have at least one other member is to store the size of the array
alongside it.

As for the request to relax the stricter C++ rules with -fpermissive, while I
defer to Jason and others, my inclination is not to unless it turns out that
the use case of having just a zero-length array and a flexible array as the
sole members is a common idiom.

Regarding the test case in the attachment, I'm not sure I understand the
purpose of having two arrays that are essentially equivalent.  Flexible array
members were introduced into the language as a replacement of zero-length
arrays (to avoid what's known as the struct hack).  But if having two such
arrays is nececcary for some reason, changing the flexible array member to a
zero-length array should get around the error in an ABI/API compatible way.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]