c/4247: gcc fills variable with random data
twiine@web.de
twiine@web.de
Thu Sep 6 05:06:00 GMT 2001
>Number: 4247
>Category: c
>Synopsis: gcc fills variable with random data
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Thu Sep 06 05:06:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: twiine@web.de
>Release: gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
SuSE Linux 7.0 (Kernel 2.2.16)
>Description:
The expression result[c++] = files; sets the c variable to a random value. (Seems to be c = files + 1). The problem only appears when c is initialized with -1.
The error also occurs with the latest snapshot of gcc.
Command line: gcc -Wall -o test test.c
>How-To-Repeat:
int main(int argc, char *argv[])
{
char *files, *result[5];
int c=-1;
result[c++] = files;
return 0;
}
>Fix:
The expression
c++;
result[c] = files;
works fine or if you enable optimzing.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list