Bug 860914

Summary: C89 standard violation of %f specifier in fscanf()
Product: [Fedora] Fedora Reporter: gmper <bugzilla-mail-box>
Component: glibcAssignee: Jeff Law <law>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 14CC: fweimer, jakub, law, pfrankli, schwab, spoyarek
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-27 18:14:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description gmper 2012-09-27 05:31:39 UTC
Description of problem:
There is an example in the C89 standard in the "4.9.6.2 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):
gcc 4.5.1


How reproducible:
#include <stdio.h>

int main(void)
{
    int n;
    float f;
    char c = 'x';
    
    n = scanf("%f%c", &f, &c);
    
    printf("%d %f %d\n", n, f, c);
    return 0;
}
  

Actual results:
[guest@localhost std]$ .ansi t.c -o t
[guest@localhost std]$ ./t
100e
2 100.000000 10
[guest@localhost std]$ alias .ansi
alias .ansi='gcc -ansi -pedantic -Wall'
[guest@localhost std]$


Expected results:
from the standard '/* "100e" fails to match "%f" */'
so scanf() should return EOF


Additional info:
C99 and C11 standards contain the same example

Comment 1 gmper 2012-09-27 05:59:38 UTC
-so scanf() should return EOF
+so scanf() should return 0

Comment 2 Jeff Law 2012-09-27 18:14:59 UTC
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.

Thanks,
Jeff