This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/128: Re: gcc 2.95.2 doesn't fully zero-initialize character arrays



>Number:         128
>Category:       c
>Synopsis:       gcc 2.95.2 doesn't fully zero-initialize character arrays
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          analyzed
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 23 01:06:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Martin Sebor <sebor@roguewave.com>
>Release:        2.95.2
>Organization:
>Environment:
>Description:
 Original-Message-ID: <38D9A9FE.2699231C@roguewave.com>
 Date: Wed, 22 Mar 2000 22:22:06 -0700

 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 ();
 }

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]