This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/36304] A variable is reset for no apparent reason
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 May 2008 23:51:52 -0000
- Subject: [Bug c/36304] A variable is reset for no apparent reason
- References: <bug-36304-16219@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pinskia at gcc dot gnu dot org 2008-05-22 23:51 -------
This is not a bug as %s scans a string so the last &x[7] will overwrite past
the array.
Doing:
char x[9];
int k = i;
sscanf(in[k], "%s %s %s %s %s %s %s %s", &x[0], &x[1], &x[2], &x[3], &x[4],
&x[5], &x[6], &x[7]);
printf("i: %d\n", i);
Fixes the issue but you really should use %c instead.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36304