Menu

#252 Problem printing unsigned long longs

OTHER
closed
nobody
gcc (462)
duplicate
Duplicate
2013-01-31
2003-01-02
No

I am using gcc 3.2:

C:\Temp>gcc --version
gcc (GCC) 3.2 (mingw special 20020817-1)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying
conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.

C:\Temp>gcc -v
Reading specs from C:/MinGW/bin/../lib/gcc-
lib/mingw32/3.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld -
-with-gnu-as --host=mingw32 --target=mingw32 --
prefix=/mingw
--enable-threads --disable-nls --enable-
languages=f77,c++,objc,ada --disable-win32-registry --
disable-shared
Thread model: win32
gcc version 3.2 (mingw special 20020817-1)

My operating system is Windows XP Pro SP-1.

This trivial C program demonstrates the bug:

#include <stdio.h>

int main(void) {
printf("Lines should be identical:\n");
printf("A4506CEBDE82BDE9\n");
printf("%016llX\n", 0xA4506CEBDE82BDE9ULL);
return 0;
}

It outputs:

C:\Temp>bug
Lines should be identical:
A4506CEBDE82BDE9
00000000DE82BDE9

The error also occurs in C++ programs.

I initially experienced the bug in a program that printed
eight unsigned long longs; it worked properly when
compiled with DJGPP but crashed when compiled with
MinGW.

This test case triggers the crash:
#include <stdio.h>

int main(void) {
printf("Second and third lines should be identical to
first, followed by foo:\n");
printf("A4506CEBDE82BDE9\n");
printf("%016llX\n%016llX\n%s\n",
0xA4506CEBDE82BDE9ULL,
0xA4506CEBDE82BDE9ULL, "foo");
return 0;
}

Thanks,
Stephan T. Lavavej
stlAT_CALTECH_NOT_MIT@mit.edu

Discussion

  • Stephan T. Lavavej

    Logged In: YES
    user_id=679420

    It looks like I've duplicated a bug report submitted mere hours
    before mine; I apologize.

    However, it is definitely a bug. The ll length modifier is
    definitely C99; see section 7.19.6.1 of the Standard.

     
  • Danny Smith

    Danny Smith - 2003-01-02

    Logged In: YES
    user_id=11494

    Duplicate of 661165

     
  • Danny Smith

    Danny Smith - 2003-01-02
    • status: open --> closed-duplicate
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-31
    • labels: --> gcc
    • status: closed-duplicate --> closed
    • resolution: --> duplicate
    • category: --> Duplicate
    • milestone: --> OTHER