http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47090
Summary: Incorrect parsing by ssanf/fscanf with scanset. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: gaven...@gmail.com This happen with gcc (GCC) 4.3.4 20090804 (release) 1 from Cygwin and gcc (GCC) 4:4.3.2-2 from Debian. $ cat 1.c #include <stdio.h> int main() { char str[30] = "==============="; char ch = '!'; int cnt = sscanf("hello\n", "%5s%1[\n]", str, &ch); printf("xxx%sxxx\n%d\nyyy%czzz", str, cnt, ch); return 0; } $ gcc 1.c -o 1.exe && ./1.exe xxxxxx # I expect get xxxhelloxxx 2 yyy zzz $ sed -i 's=%5s=%10s=' 1.c $ gcc 1.c -o 1.exe && ./1.exe xxxxxx # I expect get xxxhelloxxx 2 yyy zzz $ sed -i 's=%10s=%4s=' 1.c xxxhellxxx # Seems all OK 1 yyy!zzz