Using sizeof() with classes is borked
Submitted by Poprádi Árpád
Link to original bug (#728274)
Description
From version 0.23.2 the GDK event structures are compact classes. To create/setup/destroy them manually this kind of code should work:
Gdk.EventKey* eventkey = (Gdk.EventKey*) GLib.malloc (sizeof (Gdk.EventKey)); (*eventkey).keyval = (uint)Gdk.Key.k; GLib.free(eventkey);
but it results error: Pointer indirection not supported for this expression (*eventkey).keyval = (uint)Gdk.Key.k; ^^^^^^^^^
This version: Gdk.EventKey* eventkey = (Gdk.EventKey*) GLib.malloc (sizeof (Gdk.EventKey)); eventkey->keyval = (uint)Gdk.Key.k; GLib.free(eventkey);
compiles but results in: free(): invalid next size (fast): 0x0000000001240010 ***
without the line "eventkey->keyval = (uint)Gdk.Key.k" compiles and runs without error.
Version: 0.24.x