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 710863 - Missing cast for g_value_set_pointer() on generic property value
Missing cast for g_value_set_pointer() on generic property value
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Generics
unspecified
Other All
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-10-25 09:47 UTC by Philip Withnall
Modified: 2018-05-22 14:58 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Withnall 2013-10-25 09:47:20 UTC
If a generic class (with type parameter T) has a property of type T, the generated C code will use g_value_[get|set]_pointer() for the property marshalling. However, it will pass the value from the property’s getter method (which has return type gconstpointer) into g_value_set_pointer(), which takes a gpointer. This means GCC will complain about discarding the const qualifier from the pointer because Vala is violating the C type system.

For example:

public abstract class Folks.AbstractFieldDetails<T> : Object
{
  public virtual T @value
    {
      get { return this._value; }
      construct set { this._value = value; }
    }
}

generates the following:

static void _vala_folks_abstract_field_details_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	…
	switch (property_id) {
		case FOLKS_ABSTRACT_FIELD_DETAILS_VALUE:
		g_value_set_pointer (value, folks_abstract_field_details_get_value (self));
		break;
		…
	}
}

gconstpointer folks_abstract_field_details_get_value (FolksAbstractFieldDetails* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return FOLKS_ABSTRACT_FIELD_DETAILS_GET_CLASS (self)->get_value (self);
}


This is with Vala 0.22.0.26-f79fe.
Comment 1 GNOME Infrastructure Team 2018-05-22 14:58:07 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/413.