After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 672752 - Vala copies arrays on assignment
Vala copies arrays on assignment
Status: RESOLVED DUPLICATE of bug 650663
Product: vala
Classification: Core
Component: Arrays
0.15.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2012-03-24 14:13 UTC by Alexander Kurtz
Modified: 2017-03-09 16:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ValaDemo.vala (172 bytes, text/plain)
2012-03-24 14:13 UTC, Alexander Kurtz
Details
ValaDemo.c (8.39 KB, text/plain)
2012-03-24 14:14 UTC, Alexander Kurtz
Details
JavaDemo.java (176 bytes, text/plain)
2012-03-24 14:15 UTC, Alexander Kurtz
Details
CDemo.c (184 bytes, text/plain)
2012-03-24 14:15 UTC, Alexander Kurtz
Details

Description Alexander Kurtz 2012-03-24 14:13:36 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
Comment 1 Alexander Kurtz 2012-03-24 14:14:43 UTC
Created attachment 210517 [details]
ValaDemo.c
Comment 2 Alexander Kurtz 2012-03-24 14:15:08 UTC
Created attachment 210518 [details]
JavaDemo.java
Comment 3 Alexander Kurtz 2012-03-24 14:15:44 UTC
Created attachment 210519 [details]
CDemo.c
Comment 4 Rico Tzschichholz 2017-03-09 16:08:28 UTC

*** This bug has been marked as a duplicate of bug 650663 ***