Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1315 GCC 4.4.0 "unknown conversion type character 'l' in format"

OTHER
closed
nobody
gcc (462)
invalid
Behaves_as_Documented
2013-01-21
2009-07-08
No

When compiling:

#include <stdio.h>
int main( int argc, char*argv[] ) {
unsigned long long i;
sscanf(argv[1], "%llu", &i);
printf("%llu", i);
return 0
}

I get this warnings:
C:\tmp>g++ tst.cpp
tst.cpp: In function 'int main(int, char**)':
tst.cpp:7: error: expected ';' before '}' token

C:\tmp>g++ -Wall tst.cpp
tst.cpp: In function 'int main(int, char**)':
tst.cpp:4: warning: unknown conversion type character 'l' in format
tst.cpp:4: warning: too many arguments for format
tst.cpp:5: warning: unknown conversion type character 'l' in format
tst.cpp:5: warning: too many arguments for format

C:\tmp>a 16409049846434354
2738014770
C:\tmp>

As you can see, it interprets the unsigned long long as a 32 integer, and not 64 bit one...

Grtz,
Steven

Discussion

  • Keith Marshall
    Keith Marshall
    2009-07-09

    > As you can see, it interprets the unsigned long long as a 32 integer,
    > and not 64 bit one...

    Which is exactly as you should expect, when you use the standard Microsoft implementations of printf, scanf and friends, (as MinGW does).

    If you are using mingwrt-3.15 or later, it provides an alternative implementation of printf and friends, (but not scanf and friends), which does accept ISO-C99 format specifiers; however, for truly portable code, you should learn to use inttypes.h to formulate portable format specification strings.

     
  • Keith Marshall
    Keith Marshall
    2009-07-09

    • milestone: --> Behaves_as_Documented
    • status: open --> closed-invalid
     
  • Earnie Boyd
    Earnie Boyd
    2013-01-21

    • status: closed-invalid --> closed
    • resolution: --> invalid
    • category: --> Behaves_as_Documented
    • milestone: Behaves_as_Documented --> OTHER
     
  • Earnie Boyd
    Earnie Boyd
    2013-01-21