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 540670 - Cannot pass const values to function without warning.
Cannot pass const values to function without warning.
Status: RESOLVED DUPLICATE of bug 539703
Product: vala
Classification: Core
Component: Arrays
0.3.x
Other All
: Low minor
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2008-06-28 19:36 UTC by Stef Walter
Modified: 2009-07-27 15:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Stef Walter 2008-06-28 19:36:24 UTC
Passing const values to a function results in a warning. We also cannot declare the function as accepting a const value (not sure if this is a good idea or not).

/* 
 * valac test.vala
 */

using GLib;

public class Test : GLib.Object {
	private static const int[] NUMBERS = {
		1, 2, 3
	};
	public static void test(int[] numbers) {

	}
	public static void main(string[] args) {
		test(NUMBERS);
	}
}

Compiler warning:

test.c: In function ‘test_main’:
test.c:23: warning: passing argument 1 of ‘test_test’ discards qualifiers from pointer target type
Comment 1 Jürg Billeter 2009-04-15 19:12:47 UTC
Confirming, requires decision how to handle const arrays compared to buffer parameters.
Comment 2 Jürg Billeter 2009-07-27 15:39:49 UTC
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 539703 ***