This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 2.95.2 doesn't fully zero-initialize character arrays
- To: gcc bug list <gcc-bugs at gcc dot gnu dot org>
- Subject: gcc 2.95.2 doesn't fully zero-initialize character arrays
- From: Martin Sebor <sebor at roguewave dot com>
- Date: Wed, 22 Mar 2000 22:22:06 -0700
- CC: John Pedretti <pedretti at roguewave dot com>
Hi,
gcc doesn't zero out explicitly uninitialized elements of a character array
(required by 6.7.8, p21 of C99 - this seems to be a change from C89).
Regards
Martin
PS This is not a bug report since C99 wasn't ratified until the end of '99.
Test case: on i86 when built with no compiler options the program returns 1, 0
is expected.
int foo ()
{
char s[2] = "";
return 0 == s[1];
}
int main ()
{
{ // dirty up the stack
char s[] = "x";
}
return !foo ();
}