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


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]