This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/13896] 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 16:51:58 -0000
- Subject: [Bug c/13896] Initializer string warning not printed if implied NULL-terminator out of bounds
- References: <20040128132357.13896.rhajdaj@yahoo.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rhajdaj at yahoo dot com 2004-01-28 16:51 -------
I suppose it's blasphemy to disagree with that requirement, but since '\0' is
indeed an element of any array containing it (implicitly or otherwise), it's my
opinion that the requirement (though it might satisfy the letter of some law),
disagrees with descriptions of string literals like (K & R p. 38):
"The internal representation of a string has a null character '\0' at the end,
so the physical storage required is one more than the number of characters
written between the quotes."
So a[0][] (using the a[][3] = {{"Hel"}, {"Hi"}} example) must take up 4 bytes.
Given the requirement, you're right. I got nothin. But the requirement seems
bogus to me.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13896