GNOME Bugzilla – Bug 710865
Incorrect cast on accessing a property from an abstract parent class
Last modified: 2017-03-11 15:47:01 UTC
If I have a Gee.HashMap and access its .values property, the generated C code will (correctly) call gee_abstract_map_get_values(). However, the object passed to that call will be cast to (GeeMap*) (which is the interface implemented by GeeAbstractMap) — it should instead be cast to (GeeAbstractMap*). This causes GCC to print the following warning, specifying that we’re violating the C type system: backend-store.c: In function '_folks_backend_store_get_modules_from_dir_co': backend-store.c:2636:8: warning: passing argument 1 of 'gee_abstract_map_get_entries' from incompatible pointer type [enabled by default] _data_->_tmp39_ = gee_abstract_map_get_entries ((GeeMap*) G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp38_, GEE_TYPE_HASH_MAP, GeeHashMap)); ^ In file included from backend-store.c:30:0: /opt/gnome3/build/include/gee-0.8/gee.h:1457:9: note: expected 'struct GeeAbstractMap *' but argument is of type 'struct GeeMap *' Test case coming. This is with Vala 0.22.0.26-f79fe.
Created attachment 258089 [details] Vala test case Here’s the Vala test case.
Created attachment 258090 [details] Generated C code for test case Here’s the generated C code. The problem is on line 37.
*** This bug has been marked as a duplicate of bug 779219 ***