GNOME Bugzilla – Bug 593859
Accessing the length of a function that returns an array does not emit the function call in C
Last modified: 2009-09-15 17:13:02 UTC
I observed this behavior with KeyFile.get_groups(). Vala testcase: extern string[] get_strings (); void print_string_count () { message ("string count: %d", get_strings ().length); } Generated code (in both 0.7.4 and 0.7.6~git, as of 2009/09/01): char** get_strings (int* result_length1); void print_string_count (void); static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func); static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func); void print_string_count (void) { gint _tmp1__length1; char** _tmp1_; gint _tmp0_; _tmp1_ = NULL; g_message ("array-return-test.vala:4: string count: %d", _tmp0_); _tmp1_ = (_vala_array_free (_tmp1_, _tmp1__length1, (GDestroyNotify) g_free), NULL); } // definitions for _vala_array_destroy and _vala_array_free If you replace the message() statement above with the following code, it emits the correct C: string[] res; res = get_strings (); message ("string count: %d", res.length);
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 585847 ***