GNOME Bugzilla – Bug 619153
Nullable out parameter segfault when checked for null
Last modified: 2010-06-16 19:51:28 UTC
This function: void out_class(out Class? c) { if (c != null) c = new Class(); } generates this C code: void out_class (Class** c) { if (c != NULL) { *c = NULL; } // The problem is here when c is NULL if ((*c) != NULL) { Class* _tmp0_; *c = (_tmp0_ = class_new (), _class_unref0 (*c), _tmp0_); } }
Created attachment 161508 [details] Minimal test case
SImply you can't pass null to out parameters, Vala does not null check each operation, otherwise you'll end up with a bunch of null checks. This is a limitation of the syntax evidently that you can't access the address of the parameter... I don't know if this is good or not.
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of bug 591673 ***