Xref: utzoo gnu.gcc:1242 gnu.gcc.bug:1829 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!think!snorkelwacker!bloom-beacon!shelby!mcnc!thorin!unc!alexande From: alexande@unc.cs.unc.edu (Geoffrey D. Alexander) Newsgroups: gnu.gcc,gnu.gcc.bug Subject: Possible gcc bug in sscanf Keywords: GNU C, sscanf, bug Message-ID: <11393@thorin.cs.unc.edu> Date: 10 Jan 90 17:46:48 GMT Sender: news@thorin.cs.unc.edu Lines: 39 I have encountered what I believe to be a GNU C bug in sscanf. The problem is illustrated by the following program. #include 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