GNOME Bugzilla – Bug 672752
Vala copies arrays on assignment
Last modified: 2017-03-09 16:08:28 UTC
Created attachment 210516 [details] ValaDemo.vala Hi, the Vala Reference Manual says[0] that "Reference types include [...] array types", however Vala still seems to copy arrays on assignment: $ cat ValaDemo.vala class ValaDemo { public static void main(string[] args){ int[] array1 = new int[10]; int[] array2 = array1; array2[0] = 42; stdout.printf("%d\n", array1[0]); } } $ valac-0.16 --version Vala 0.15.2 $ valac-0.16 --save-temps ValaDemo.vala $ ./ValaDemo 0 $ Please note that the program prints "0" instead of "42" which I would have expected. I have attached the Vala source code and the generated C code. I have also attached corresponding Java and C programs which all work as expected. Best regards Alexander Kurtz [0] http://www.vala-project.org/doc/vala-draft/types.html
Created attachment 210517 [details] ValaDemo.c
Created attachment 210518 [details] JavaDemo.java
Created attachment 210519 [details] CDemo.c
*** This bug has been marked as a duplicate of bug 650663 ***