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

Jakub Jelinek jakub@redhat.com
Tue Jul 17 08:32:00 GMT 2001


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



More information about the Libc-alpha mailing list