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 572612 - Mistakenly substitute -1 with G_MAXULONG in x86_64
Mistakenly substitute -1 with G_MAXULONG in x86_64
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-02-20 21:49 UTC by Matthias Clasen
Modified: 2009-03-09 10:42 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Matthias Clasen 2009-02-20 21:49:51 UTC
Fedora bug: https://bugzilla.redhat.com/show_bug.cgi?id=480563

I have both i386 and x86_64 machines, and the problem only occur in my x86_64.

Following program demonstrate the problem in x86_64:
/* Begin of show64.c */
#include <stdlib.h>
#include <stdio.h>
#include <glib-object.h>

static gchar*
describe_signed_constant (gint64 value)
{
  gchar *desc;

  if (value == G_MINLONG)
    desc = g_strdup ("G_MINLONG");
  else if (value == G_MAXULONG)
    desc = g_strdup ("G_MAXULONG");
  else if (value == G_MAXINT64)
    desc = g_strdup ("G_MAXINT64");
  else if (value == G_MININT64)
    desc = g_strdup ("G_MININT64");
  else
    desc = g_strdup_printf ("%" G_GINT64_FORMAT, value);

  return desc;
}

int main(int argc,char *argv[]){
  printf("describe_signed_constant (-1):%s\n",describe_signed_constant (-1));
  return 0;
}
/* End of show64.c*/


Compile it using:
gcc -o show64 show64.c `pkg-config --cflags --libs glib-2.0`

Run it with:
./show64

And the result is:
describe_signed_constant (-1):G_MAXULONG

Where the result should be:
describe_signed_constant (-1):-1

Similar code segement is in code generation part in gtkdoc-scangobj,
specifically, search "describe_signed_constant (gint64 value)" in
gtkdoc-scangobj
to see what I am talking about.

Maybe removing unsigned constant in static gchar* describe_signed_constant
(gint64 value) 
fix the problem.
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2009-03-04 09:41:55 UTC
I don't have access to any 64bit machine :/. But wouldn't it a better fix to change it like this? Same for unsigned constant.

static gchar*
describe_signed_constant (guint size, gint64 value)
{
  gchar *desc = NULL;

  switch (size)
  {
    case 8:
      ...
      break;
    case 16:
      ...
      break;
    case 32:
      if (value == G_MINLONG)
        desc = g_strdup ("G_MINLONG");
      else if (value == G_MAXULONG)
        desc = g_strdup ("G_MAXULONG");
      break;
    case 64:
      if (value == G_MAXINT64)
        desc = g_strdup ("G_MAXINT64");
      else if (value == G_MININT64)
        desc = g_strdup ("G_MININT64");
    default:
      g_warning("unsupported size");
   }
   if(!desc)
     desc = g_strdup_printf ("%" G_GINT64_FORMAT, value);

  return desc;
}
Comment 2 Matthias Clasen 2009-03-07 19:50:39 UTC
sure, that would work too
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2009-03-09 10:42:11 UTC
Please reopen, if my changes do not help.

2009-03-09  Stefan Kost  <ensonic@users.sf.net>

	* gtkdoc-scangobj.in:
	  Don't confuse -1 with G_MAXULONG on 64bit. Fixes #572612.