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 641308 - "string args[]" is not equal to "string []args"
"string args[]" is not equal to "string []args"
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Arrays
unspecified
Other Linux
: Normal major
: 0.42
Assigned To: Vala maintainers
Vala maintainers
: 623857 642040 (view as bug list)
Depends on:
Blocks: 664412 733017
 
 
Reported: 2011-02-02 23:52 UTC by Giulio Paci
Modified: 2018-05-22 13:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
valaparser: don't allow to declare an array using type array[] (1.00 KB, patch)
2011-02-05 14:41 UTC, Marco Trevisan (Treviño)
needs-work Details | Review
valaparser: Don't allow to declare array parameters with "type array[]" (1.85 KB, patch)
2017-07-08 19:04 UTC, Rico Tzschichholz
none Details | Review
codegen: Generate correct ccode for fixed-length array parameters (5.14 KB, patch)
2017-07-08 19:04 UTC, Rico Tzschichholz
none Details | Review
codegen: Generate correct ccode for fixed-length array parameters (5.17 KB, patch)
2018-02-21 11:12 UTC, Rico Tzschichholz
none Details | Review

Description Giulio Paci 2011-02-02 23:52:44 UTC
This simple vala program compiles with warning in both vala 0.10.x and 0.11.4. 

int main(string args[])
{
	stdout.printf(args[1] + "\n");
	return 0;
}

Executing this program gives segmentation fault because "string args[]" generates "gchar *args"/"char *args" in C, instead of "gchar **args"/"char **args".
Comment 1 Marco Trevisan (Treviño) 2011-02-05 14:41:51 UTC
Created attachment 180171 [details] [review]
valaparser: don't allow to declare an array using type array[]

I guess that this syntax shouldn't be allowed (as it isn't in C#), the attached patch fixes it (showing an error).

Of course this syntax could be easily be allowed, but I guess this is not in the intentions of developers...
Comment 2 Jürg Billeter 2011-02-07 22:01:42 UTC
Comment on attachment 180171 [details] [review]
valaparser: don't allow to declare an array using type array[]

This is too restrictive. The following is a valid declaration that would be broken by your patch, if I read the patch correctly:

const int foo[] = { 1, 2, 3 };

However, it is unsupported for parameters outside the dova profile.
Comment 3 Marco Trevisan (Treviño) 2011-02-07 22:20:59 UTC
No, I thought the same after posting it, (in fact I wanted to re-submit it), but that code it's not broken with the attached patch... :P
Comment 4 Rico Tzschichholz 2016-10-11 12:46:14 UTC
*** Bug 642040 has been marked as a duplicate of this bug. ***
Comment 5 Rico Tzschichholz 2017-03-09 20:51:42 UTC
*** Bug 623857 has been marked as a duplicate of this bug. ***
Comment 6 Rico Tzschichholz 2017-07-08 19:04:48 UTC
Created attachment 355179 [details] [review]
valaparser: Don't allow to declare array parameters with "type array[]"

It is required to have a fixed length like "type array[3]".
Comment 7 Rico Tzschichholz 2017-07-08 19:04:54 UTC
Created attachment 355180 [details] [review]
codegen: Generate correct ccode for fixed-length array parameters
Comment 8 Rico Tzschichholz 2018-02-21 11:12:47 UTC
Created attachment 368703 [details] [review]
codegen: Generate correct ccode for fixed-length array parameters
Comment 9 GNOME Infrastructure Team 2018-05-22 13:53:43 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/163.