alexande@unc.cs.unc.edu (Geoffrey D. Alexander) (01/11/90)
I have encountered what I believe to be a GNU C bug in sscanf. The problem is
illustrated by the following program.
#include <stdio.h>
main () {
int a;
int b;
int c;
int d;
static char buffer[]="1 2 3 4 ";
int rc;
rc=sscanf(buffer, "%d %n %d %n", &a, &b, &c, &d);
fprintf(stdout, "rc: %d\na: %d\nb: %d\nc: %d\nd: %d\n", rc, a, b, c, d);
exit(0);
}
When compiled with "cc test.c -O -o test", I get the following results.
rc: 2
a: 1
b: 2
c: 2
d: 4
This is what I expected . When I compile with "gcc test.c -O -o test", I get
the following results.
rc: 1
a: 1
b: 0
c: 0
d: 0
It seems that %n is not processed correctly. Is this a valid bug? Note that
I am running gcc version 1.36 under SunOS Release 4.0.3 on a Sun-3/60M. Any
help would be appreciated.
Thanks,
Geoff