This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13896] New: Initializer string warning not printed if implied NULL-terminator out of bounds
- From: "rhajdaj at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jan 2004 13:23:58 -0000
- Subject: [Bug c/13896] New: Initializer string warning not printed if implied NULL-terminator out of bounds
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
If the following string array is declared,
char a[][3] = {{"Hello"}, {"Hi"}};
the following warning will be printed when the source file is compiled:
warning: initializer-string for array of chars is too long
warning: (near initialization for `a[0]')
If the array is changed to this,
char a[][3] = {{"Hel"}, {"Hi"}};
no warning is printed. But of course a[1][0] ('H') overwrites the NULL-
terminator at a[0][3], so a[0] prints as "HelHi". A warning should be printed
for this.
--
Summary: Initializer string warning not printed if implied NULL-
terminator out of bounds
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rhajdaj at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13896