This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

["Vadim Zhukovsky" <zva@ukrpost.net>] scanf bug



The appended bug report is not resolved yet.  Could somebody look into
it, please?

Andreas



Topics:
   Re: scanf bug



This is the program and the result:

#include <stdio.h>
#include <stdlib.h>

const char *oct_long_long = "01000000000000000000000";

void main()
{
  long long ll1, ll2;
  sscanf(oct_long_long, "%Lo", &ll1);
  sscanf(oct_long_long, "%Li", &ll2);
  printf("%%Lo: %Ld, %%Li: %Ld\n", ll1, ll2);
}
----------------------------------------------------------------
%Lo: -9223372036854775808, %Li: 9223372036854775807

The Lo specifier produces the right result, Li - wrong.
01000000000000000000000 = LLONG_MIN
The same thing happens when scanning 
"0777777777777777777777" = LLONG_MAX
or "01777777777777777777777" = ULLONG_MAX

Test was performed on glibc - 2.0.7 and 2.1.92

Best wishes, 

Vadim Zhukovsky


----- Original Message ----- 
From: "Andreas Jaeger" <aj@suse.de>
To: "Vadim Zhukovsky" <zva@ukrpost.net>
Cc: <bug-glibc@gnu.org>
Sent: Friday, June 15, 2001 11:10 PM
Subject: Re: scanf bug


"Vadim Zhukovsky" <zva@ukrpost.net> writes:

> long long ll;
> sscanf("01000000000000000000000", "%Li", &ll);
> sscanf("0777777777777777777777", "%Li", &ll);
> ll is not what expected to be

So what do you expect as answer - and what do you get?

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj



_______________________________________________
Bug-glibc mailing list
Bug-glibc@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-glibc







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