I have the following code:
#include <cstdint>
struct parent
{
uint64_t id;
char data[];
};
struct child : public parent
{
uint32_t tmp;
char text[];
};
int main() {
child d;
d.id = 1;
}
When compiled with GCC 7.2.1, it gave me errors:
flex.cpp:6:20: error: flexible array member ‘parent::data’ not at end of ‘struct child’
char data[];
^
flex.cpp:11:13: note: next member ‘uint32_t child::tmp’ declared here
uint32_t tmp;
^~~
flex.cpp:9:8: note: in the definition of ‘struct child’
struct child : public parent
^~~~~
When compiled with GCC 4.8.5, it's fine with no warning nor error.
A bug in GCC 4.8.5?
Thanks in advance!