GNOME Bugzilla – Bug 575628
Check expression type of constant initializers
Last modified: 2009-09-17 15:40:25 UTC
Please describe the problem: The following legal vala code leads to illegal c code: using GLib; const KeyFile keyfile = new KeyFile(); public static int main( string[] args ) { var context = new MainContext(); return 0; } Steps to reproduce: gint _main (char** args, int args_length1) { GKeyFile* _tmp0; GMainContext* _tmp0; GMainContext* context; gint _tmp1; _tmp0 = NULL; _tmp0 = NULL; context = (_tmp0 = g_main_context_new (), (_tmp0 == NULL) ? NULL : (_tmp0 = (g_key_file_free (_tmp0), NULL)), _tmp0); return (_tmp1 = 0, (context == NULL) ? NULL : (context = (g_main_context_unref (context), NULL)), _tmp1); } int main (int argc, char ** argv) { g_type_init (); return _main (argv, argc); } Actual results: Expected results: Does this happen every time? Other information:
As object creation expressions are not constant expressions, they are not supported as initializer for constants. Your example is incorrect, the semantic analyzer just fails to detect the error.
*** Bug 585292 has been marked as a duplicate of this bug. ***
Thanks for taking the time to report this bug. This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed. It should be solved in the next software version. You may want to check for a software upgrade. *** This bug has been marked as a duplicate of bug 587947 ***