Root cause (credit Richard Biener) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115432
struct file_output_stream {
union { void *voidp; int fd; } data;
const output_stream_vtbl* vtbl; };
struct output_stream { void* data; const output_stream_vtbl* vtbl; };
those are two unrelated types. Doing
((file_output_stream *)p)->vtbl = x; ... = ((output_stream *)p)->vtbl;
is invoking undefined behavior (unless -fno-strict-aliasing).
Root cause (credit Richard Biener) https:/ /gcc.gnu. org/bugzilla/ show_bug. cgi?id= 115432
struct file_output_stream
{
union
{
void *voidp;
int fd;
} data;
const output_stream_vtbl* vtbl;
};
struct output_stream
{
void* data;
const output_stream_vtbl* vtbl;
};
those are two unrelated types. Doing
((file_ output_ stream *)p)->vtbl = x;
... = ((output_stream *)p)->vtbl;
is invoking undefined behavior (unless -fno-strict- aliasing) .