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]

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


It fits signed long long. Look at attached file in the Andreas letter

01000000000000000000000 = LLONG_MIN
The same thing happens when scanning
"0777777777777777777777" = LLONG_MAX
or "01777777777777777777777" = ULLONG_MAX

Maybe you're right about the last number, which is really doesn't fit signed
long long.

Vadim

----- Original Message -----
From: "Jakub Jelinek" <jakub@redhat.com>
To: "Andreas Jaeger" <aj@suse.de>
Cc: <libc-alpha@sources.redhat.com>; "Vadim Zhukovsky" <zva@ukrpost.net>
Sent: Tuesday, July 17, 2001 5:34 PM
Subject: Re: ["Vadim Zhukovsky" <zva@ukrpost.net>] scanf bug


> On Tue, Jul 17, 2001 at 04:28:18PM +0200, Andreas Jaeger wrote:
> >
> > The appended bug report is not resolved yet.  Could somebody look into
> > it, please?
>
> Are you sure it is a bug?
> I think ISO C99 sais about this in 7.19.6.2.10:
> ... if the result of the conversion cannot be represented in the object,
the
> behaviour is undefined.
> 7.19.6.2.12 sais 'i' conversion's argument is signed integer, and
> 01000000000000000000000 does not fit into signed long long.
>
> > #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
>
> Jakub
>


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