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 629600 - Assigning a struct method to a delegate generates malformed C-Code
Assigning a struct method to a delegate generates malformed C-Code
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Delegates
0.9.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2010-09-14 01:48 UTC by Frederik Sdun
Modified: 2018-05-22 13:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
simple testcase (217 bytes, text/x-vala)
2010-09-14 01:48 UTC, Frederik Sdun
  Details
Struct method delegate (1.53 KB, patch)
2014-01-12 00:30 UTC, Luca Bruno
none Details | Review

Description Frederik Sdun 2010-09-14 01:48:07 UTC
Created attachment 170209 [details]
simple testcase

If you assign a method to a delegate vala generates the following code:

(*self).f_target = (*self), (*self).f_target_destroy_notify = NULL

which causes the following gcc error: 

deleginstruct.vala.c:41: error: incompatible types when assigning to type ‘gpointer’ from type ‘testee’

vala should assign the pointer and maybe even set the destroy_notify for the struct
Comment 1 A. Syukri Abdollah 2012-09-29 17:32:17 UTC
Reproducible in 0.18.0
Changing (*self) to self in the generated C code allows compilation.
Comment 2 Luca Bruno 2014-01-11 23:54:45 UTC
The fix is trivial, but the semantics may not be what you expect, so I'm unsure whether to fix it or forbid using struct methods for delegates altogether.
The problem is with owned delegates: a struct is not referenced counted, so what destroy notify should do? Shall we copy the struct? What kind of transfer ownership? And so on.
All of this is very counter intuitive because structs are not referenced counted.
Comment 3 Luca Bruno 2014-01-12 00:30:32 UTC
Created attachment 266036 [details] [review]
Struct method delegate

Reference patch, to not by committed by any means.
Comment 4 GNOME Infrastructure Team 2018-05-22 13:44:42 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/131.