GNOME Bugzilla – Bug 706683
fails to build with latest stable Vala
Last modified: 2013-08-28 10:00:31 UTC
Created attachment 252931 [details] [review] PhoneFieldDetailsTests: make constant static strings unowned This works around Vala bug GNOME#646970, which is only fixed in a development version (0.21). Newer Vala versions automatically make these strings behave as if unowned anyway. --- Yes I realize this is a workaround, but it's so easy that it seems worth doing.
What’s the build failure you get? It’s building fine for me with Vala from a few days ago.
(In reply to comment #1) > What’s the build failure you get? It’s building fine for me with Vala from a > few days ago. Note that I said "latest stable" - it fails with 0.20.1 (the latest even-numbered release) but works with 0.21.x. The compiler error with "-g" is: /home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala: In function ‘phone_field_details_tests_test_normalisation’: /home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala:42:2: error: initializer element is not constant const NormalisationPair[] normalisation_pairs = { ^ The generated code is: void phone_field_details_tests_test_normalisation (PhoneFieldDetailsTests* self) { gchar* _tmp0_; gchar* _tmp1_; gchar* _tmp2_; gchar* _tmp3_; gchar* _tmp4_; gchar* _tmp5_; #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" static const PhoneFieldDetailsTestsNormalisationPair normalisation_pairs[] = {{_tmp0_, _tmp1_}, {_tmp2_, _tmp3_}, {_tmp4_, _tmp5_}}; #line 38 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" g_return_if_fail (self != NULL); #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" _tmp0_ = g_strdup ("1-800-123-4567"); #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" _tmp1_ = g_strdup ("18001234567"); #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" _tmp2_ = g_strdup ("+1-800-123-4567"); #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" _tmp3_ = g_strdup ("+18001234567"); #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" _tmp4_ = g_strdup ("+1-800-123-4567P123"); #line 42 "/home/smcv/src/gnome/folks/tests/folks/phone-field-details.vala" _tmp5_ = g_strdup ("+18001234567P123"); which clearly isn't going to work (even if these non-constant initializers for a static object were valid C, normalisation_pairs[] contains uninitialized pointers and is never updated to contain the desired strings, so the rest of the function would just crash).
Comment on attachment 252931 [details] [review] PhoneFieldDetailsTests: make constant static strings unowned Sorry, missed that you’d said ‘stable’. Go for it, and don’t forget to update NEWS. Thanks!
Fixed in git for 0.9.6