This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug in sscanf for long long data?


Hello,

[ I have sent this message already on Monday to this list, however,
  I have not received it myself nor can I find it in the archives,
  so I try my luck again, sorry for a possible duplication. ]

I am using gcc version "2.95 19990728 (release)" under the cygnus 
shell version (output of uname -a) "CYGWIN_95-4.0 IHFPCUJ 21.0 
(0.8/1/1) 1999-1-16 00:09:28 i586 unknown" (the latest beta release,
no snapshot).

I have problems with the sscanf function processing data of type 
long long, the following short code illustrates this:

---------------------------------------
#include <stdio.h>

int main()
{ 
  
  long long ll;

  /* this initialisation will result in a correct output: */
  /* ll = 0; */

  /* this initialisation will result in an incorrect output */
  ll = -9999999999;

  sscanf ("123456789", "%lld", &ll);
  printf ("%lld\n", ll);

  return (0);
}
---------------------------------------

The code as printed above gives the incorrect output
   -12761445099
to the screen. However, if the statement
   ll = -9999999999; 
is replaced by the initialisation
   ll = 0;
then the output is correct:
   123456789
When ll is not being initialised, then the output is unpredictable. 

Executing the same code on a LINUX system with either gcc-2.8.1 or
gcc-2.95.1 results in the correct output in all three cases. 

Any ideas? Is this a cygwin gcc bug?

Ulrich




--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]