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 596730 - Signed vs. unsigned comparison in gtkdoc-scangobj.in causing compile errors
Signed vs. unsigned comparison in gtkdoc-scangobj.in causing compile errors
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: 1.12
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2009-09-29 12:24 UTC by Jannis Pohlmann
Modified: 2009-09-30 07:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to cast gint64 to gulong when comparing to G_MAXULONG (474 bytes, patch)
2009-09-29 12:24 UTC, Jannis Pohlmann
none Details | Review

Description Jannis Pohlmann 2009-09-29 12:24:16 UTC
Created attachment 144260 [details] [review]
Patch to cast gint64 to gulong when comparing to G_MAXULONG

Over at Xfce we recently noticed that some of our components using gtk-doc to
generate API documentation didn't pass make distcheck on our buildbot.

The log file can be seen on
http://buildbot.xfce.org/core/builders/thunar_on_buildbotD/builds/26/steps/make%20distcheck/logs/stdio,
but the essential part is this:

cc1: warnings being treated as errors
thunarx-scan.c: In function ‘describe_signed_constant’:
thunarx-scan.c:884: error: comparison between signed and unsigned
Compilation of scanner failed: 
make[3]: *** [scan-build.stamp] Error 1

I looked at the gtk-doc source code and found out that in gtkdoc-scangobj.in, a
gint64 value is compared to G_MAXULONG (which is gulong). I know that our
compiler flags are very strict, but still, this can be fixed in gtk-doc easily.

Attached is a patch against HEAD that casts the value to gulong when comparing
it to G_MAXULONG. We tested this and it works.
Comment 1 Jannis Pohlmann 2009-09-29 16:00:23 UTC
This is not resolved yet, but after some discussion on IRC I have to correct some of my comments.

G_MAXULONG fits into gint64 but gint64 doesn't fit into gulong. So casting gint64 to gulong is bad. But still, we have a unsigned value (G_MAXULONG) compared to a signed value (the gint64 value). As G_MAXULONG will always fit into gint64, we can probably safely cast it to gint64 and thus, make the comparison

  value == (gint64) G_MAXULONG

instead of the original
 
  value == G_MAXULONG

The warning (it's just an error because of -Werror, I suppose) can be worked around with gcc by passing -Wno-sign-compare to the compiler. This is what we do for some components which is also why we don't get the error for all of them.
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2009-09-30 07:03:46 UTC
commit 982623eb8931ac6a7b6fb56159d1ed5bfe0543a7
Author: Stefan Kost <ensonic@users.sf.net>
Date:   Wed Sep 30 09:55:47 2009 +0300

    scanobj: fix signedness comparission warnings from gcc. Fixes #596730
    
    Add casts to constants.