This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/526: incorrect initialization of array
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/526: incorrect initialization of array
- From: meixner at rbg dot informatik dot tu-darmstadt dot de
- Date: 12 Sep 2000 11:38:54 -0000
- Reply-To: meixner at rbg dot informatik dot tu-darmstadt dot de
- Resent-Cc: gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Resent-Reply-To: gcc-gnats@gcc.gnu.org, meixner@rbg.informatik.tu-darmstadt.de
>Number: 526
>Category: c
>Synopsis: incorrect initialization of array
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Sep 12 04:46:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Matthias Meixner
>Release: gcc version 2.96 20000828 (experimental) + gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
>Organization:
>Environment:
Suse Linux 6.4
>Description:
When initializing an char-array with a string, the array
is not padded with NULL-bytes, if the string is shorter than
the array (e.g. char a[8]="test")
>How-To-Repeat:
/* this program should print "test@@@@" but prints "test@xxx" */
/* compile with "gcc <file>" */
#include <stdio.h>
int main()
{
char a[8]="test",b[8];
int i;
char *x;
x="xxxx";
for(i=0;i<8;i++) if(a[i]) putchar(a[i]); else putchar('@');
putchar('\n');
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: