format specifier for long long incompatible to glibc

Arno Wagner arno@wagner.name
Sat Dec 29 07:54:00 GMT 2012


Hi,

I found some old messages about this on the mailing list (from 2004) 
and since I really do not know what glibc allowed back then, I 
thought I should report this as an incompatibility.

cygwin (current version) allows only 'll' and 'q' (undocumented but
works) as specifier for long long int, while glibc allows 'll', 'L', 
and 'q'. Unfortunately, even gcc -Wall does not give a warning (and 
I did not find any other warning option that would apply) when
using 'L', it just silently (!) cuts the long long down to 32 bit.

Example:

#include <stdio.h>

void main() {
  long long i;

  i = 10000000000L;

  printf("sizeof long long: %d\n", sizeof(i));
  printf("L specifier:  %12Ld\n", i);
  printf("q specifier:  %12qd\n", i);
  printf("ll specifier: %12lld\n", i);
}

gives:

sizeof long long: 8
L specifier:    1410065408
q specifier:   10000000000
ll specifier:  10000000000

I think this should be fixed, as it may really mess up things
and, to make matters worse, only shows up when the argument exceeds 
the integer value limits, making it potentially hard to find.

Versions: 
  cygwin libc:   No idea, which package is that thing in? 
                 Installed 12/2012 though, so pretty new.
  cygwin gcc:    4.5.3

Arno
-- 
Arno Wagner,     Dr. sc. techn., Dipl. Inform.,    Email: arno@wagner.name
GnuPG: ID: CB5D9718  FP: 12D6 C03B 1B30 33BB 13CF  B774 E35C 5FA1 CB5D 9718
----
One of the painful things about our time is that those who feel certainty
are stupid, and those with any imagination and understanding are filled
with doubt and indecision. -- Bertrand Russell

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list