Red Hat Bugzilla – Bug 860914
C89 standard violation of %f specifier in fscanf()
Last modified: 2016-11-24 11:07:25 EST
Description of problem:
There is an example in the C89 standard in the "220.127.116.11 The fscanf function" section, which describes, that %f specifier cannot read "100e", because there is no exponent part after "e"
Version-Release number of selected component (if applicable):
char c = 'x';
n = scanf("%f%c", &f, &c);
printf("%d %f %d\n", n, f, c);
[guest@localhost std]$ .ansi t.c -o t
[guest@localhost std]$ ./t
2 100.000000 10
[guest@localhost std]$ alias .ansi
alias .ansi='gcc -ansi -pedantic -Wall'
from the standard '/* "100e" fails to match "%f" */'
so scanf() should return EOF
C99 and C11 standards contain the same example
-so scanf() should return EOF
+so scanf() should return 0
This is a known problem with glibc's scanf implementation. It is being tracked as bug #12437 in the glibc bug database (see External Trackers for a link).
If/when this bug is fixed upstream, we'll pick it up via our usual procedures to resync with the upstream sources.