Bug 860914 - C89 standard violation of %f specifier in fscanf()
Summary: C89 standard violation of %f specifier in fscanf()
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 14
Hardware: i686
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Jeff Law
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-09-27 05:31 UTC by gmper
Modified: 2016-11-24 16:07 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-09-27 18:14:59 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Sourceware 12437 0 None None None Never

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


Note You need to log in before you can comment on or make changes to this bug.