GNOME Bugzilla – Bug 663818
Incorrect handling of class instances passed as 'ref' parameters with --enable-checking turned on.
Last modified: 2011-11-11 20:31:53 UTC
Steps to reproduce: 1) Compile the following short program with --enable-checking: public class CLASS_ONE { public string field_one; public CLASS_ONE() { field_one = "test"; } } /***********************************/ public void do_something_with_class_one(ref CLASS_ONE victim) { victim.field_one = "test failed"; } /***********************************/ void main() { CLASS_ONE c_1 = new CLASS_ONE(); do_something_with_class_one(ref c_1); } ...and attempt to run it. Notice that an error after the following form appears: ** (process:2674): CRITICAL **: do_something_with_class_one: assertion `IS_CLASS_ONE (victim)' failed Compiling down to C code (with the command valac -C --enable-checking name_of_file.vala) reveals the following code in do_something_with_class_one(): void do_something_with_class_one (CLASS_ONE** victim) { CLASS_ONE* _tmp0_; gchar* _tmp1_; g_return_if_fail (IS_CLASS_ONE (victim)); // <---- problem _tmp0_ = *victim; ... IS_CLASS_ONE will fail, because it's expecting a pointer to a CLASS_ONE, rather than a pointer to a pointer to a CLASS_ONE.
commit 3d4112da8c4359b6df9ad97a54878e8fe567c962 Author: Luca Bruno <lucabru@src.gnome.org> Date: Fri Nov 11 21:29:54 2011 +0100 codegen: Fix type check of ref parameters Fixes bug 663818. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.