On Sat, Jul 16, 2011 at 08:51:28PM +0200, Alexander Kurtz wrote: > Hi, > > if you compile and run the attached trivial test program, this will be > the output: > > $ ./test > element.data = 42, array[23].data = 0 > $ > > If you look at the intermediate C-code, it's clear what happens: > > 70 foo_bar (&element); > 71 _tmp2_ = array[23]; > 72 foo_bar (&_tmp2_); > 73 fprintf (stdout, "element.data = %d, array[23].data = > %d\n", element.data, array[23].data); > > So while a single variable will be directly passed (by reference) to the > modifying function, an element of an array will first be copied to a > temporary variable and a reference to that temporary variable will be > passed along. Since only the temporary variable will be modified this > won't have any affect on the array. > > Unless this is the intended behavior, I think vala shouldn't copy > structs before passing them to some function when they are elements of > an array. At the very least, the behavior should be consistent > regardless whether it's an array of structs or a single struct. > > If this is already fixed or if I'm just too stupid to write correct > code, just tell me so!
Please report a bug. -- http://www.debian.org - The Universal Operating System _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
