GNOME Bugzilla – Bug 641308
"string args[]" is not equal to "string []args"
Last modified: 2018-05-22 13:53:43 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".
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 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.
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
*** Bug 642040 has been marked as a duplicate of this bug. ***
*** Bug 623857 has been marked as a duplicate of this bug. ***
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]".
Created attachment 355180 [details] [review] codegen: Generate correct ccode for fixed-length array parameters
Created attachment 368703 [details] [review] codegen: Generate correct ccode for fixed-length array parameters
-- 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.