GNOME Bugzilla – Bug 793549
Crash when using private object members in GObject-style constructor before object is constructed
Last modified: 2018-02-17 21:39:44 UTC
This dumb code segfaults at runtime: class Dumb : Object { int a; public Dumb(int a) { this.a = a; Object(); } public static void main() { new Dumb(2); } } this doesn't exist before Object() is called in the constructor. Should probably trigger a compiler error instead of a crash at runtime.
The generated code (valac 0.38.7) looks like this: Dumb* dumb_construct (GType object_type, gint a) { Dumb * self = NULL; gint _tmp0_; _tmp0_ = a; self->priv->a = _tmp0_; // <-- bad! too soon! self = (Dumb*) g_object_new (object_type, NULL); return self; }
*** This bug has been marked as a duplicate of bug 567269 ***