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 678333 - gdbus-codegen code causes warnings under -Wfloat-equal
gdbus-codegen code causes warnings under -Wfloat-equal
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
unspecified
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-06-18 15:21 UTC by Dan Winship
Modified: 2012-06-20 12:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gdbus: fix generated code to not warn under -Wfloat-equal (3.59 KB, patch)
2012-06-18 19:48 UTC, Dan Winship
none Details | Review
gdbus: fix generated code to not warn under -Wfloat-equal (3.79 KB, patch)
2012-06-19 15:34 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2012-06-18 15:21:50 UTC
gdbus-codegen's generated code includes:

      case G_TYPE_DOUBLE:
        ret = (g_value_get_double (a) == g_value_get_double (b));
        break;

Under -Wfloat-equal, this causes a warning (and NetworkManager builds with both -Wfloat-equal and -Werror).


Possible fixes:

  1. Move _g_value_equal() into libgio or libgobject so it always gets
     compiled against glib's warning flags and we don't have to worry
     about it.


  2. gdouble da = g_value_get_double (a);
     gdouble db = g_value_get_double (b);

     ret = !memcmp (&da, &db, sizeof (gdouble));


  3. Copy code from G_GNUC_BEGIN_IGNORE_DEPRECATIONS:

     #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
     _Pragma ("GCC diagnostic push")
     _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"")
     #endif

     ret = (g_value_get_double (a) == g_value_get_double (b));

     #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
     _Pragma ("GCC diagnostic pop")
     #endif
Comment 1 David Zeuthen (not reading bugmail) 2012-06-18 17:08:20 UTC
Oh, wicked! I think I'd prefer option 2, but with explicit test again the value 0 instead of using the ! operator (just to follow the existing coding style in the codegen)...
Comment 2 Dan Winship 2012-06-18 19:48:56 UTC
Created attachment 216696 [details] [review]
gdbus: fix generated code to not warn under -Wfloat-equal

FIXME: the test case doesn't actually work, because GObject emits a
notify:: even though the generated code doesn't. We'd have to assert
the proxy never receives the notification, but the existing code seems
to assume that we can't practically bound the amount of time it will
take for the proxy to receive a property change notification, so this
would have to be racy depending on the machine's load...
Comment 3 Dan Winship 2012-06-19 15:34:02 UTC
Created attachment 216757 [details] [review]
gdbus: fix generated code to not warn under -Wfloat-equal
Comment 4 David Zeuthen (not reading bugmail) 2012-06-19 16:34:21 UTC
Looks good to me - thanks for adding the test!
Comment 5 Dan Winship 2012-06-20 12:21:27 UTC
Attachment 216757 [details] pushed as 7d0db04 - gdbus: fix generated code to not warn under -Wfloat-equal