[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#592019: marked as done (gcc-4.4-base: guint64 causes printf functions to output incorrect information)



Your message dated Sat, 7 Aug 2010 02:44:57 +0200
with message-id <20100807004456.GA22639@squirrel.roonstrasse.net>
and subject line Re: gcc-4.4-base: guint64 causes printf functions to output incorrect information
has caused the Debian Bug report #592019,
regarding gcc-4.4-base: guint64 causes printf functions to output incorrect information
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
592019: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=592019
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: gcc-4.4-base
Version: 4.4.4-7
Severity: critical
Tags: squeeze
Justification: causes serious data loss

When using one of the printf functions, guint64 variables cause the following
value to be incorrectly displyed.

The following code illustrates this:
#include <stdio.h>
#include <glib.h>

int main( argv, argc ) {
        guint8 g1, g2;
        guint64 g3, g4;
        char *TS;
        TS = "This is a test";


        g1 = 1;
        g2 = 2;
        g3 = 3;
        g4 = 4;
        printf("g1 %u, g2 %u, g3 %u, g4 %u\n", g1, g2, g3, g4);
        printf("g1 %u, g3 %u, g2 %u, g4 %u\n", g1, g3, g2, g4);
        printf("g3 %u, TS %s\n", g3, TS);
        printf("g1 %u\n", g1);
        printf("g2 %u\n", g2);
        printf("g3 %u\n", g3);
        printf("g4 %u\n", g4);
        printf("TS %s\n", TS);
        return;
}

generates:
g1 1, g2 2, g3 3, g4 0
g1 1, g3 3, g2 0, g4 2
g3 3, TS (null)
g1 1
g2 2
g3 3
g4 4
TS This is a test

Note that output line 1, g4 outputs as 0, line2 g2 outputs as 0, and line 3
shows the string as NULL.



-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (600, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-- no debconf information



--- End Message ---
--- Begin Message ---
On 2010/08/07 01:16, Alex Lindberg <alindber@yahoo.com> wrote:
> When using one of the printf functions, guint64 variables cause the following
> value to be incorrectly displyed.
[...]
>         guint64 g3, g4;
>         char *TS;
>         TS = "This is a test";
>         g3 = 3;

>         printf("g3 %u, TS %s\n", g3, TS);

> g3 3, TS (null)

> Note that output line 1, g4 outputs as 0, line2 g2 outputs as 0, and line 3
> shows the string as NULL.

The output does not meet your expectations, because your code is
broken.

"%u" expects an "unsigned int" (probably 32 bits on your platform),
while you attempt to pass "guint64" (64 bits).  The result is
undefined.

You need to use G_GUINT64_FORMAT to format a guint64, see:

 http://library.gnome.org/devel/glib/unstable/glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS

Max


--- End Message ---

Reply to: