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: "trav at mac dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2004 21:44:17 -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 trav at mac dot com 2004-05-19 21:44 -------
(In reply to comment #10)
> You're right. This compiler works in agreement with the requirement, so I
> should stop bugging you guys. I guess I'm just not seeing the "why" behind the
> requirement. When in is it a perfectly acceptable condition (ie according to -
> Wall) not to null-terminate a literal string in an array like this? (I don't
> understand the "if there's room" part of the requirement.) And who do I talk
> to to challenge requirements so I can leave you alone?
>
Here is the rationale:
Since it is an array of characters, you should be able to use a convenient initializer to specify every
element of the array, including the last. Thus, you are allowed to use a double-quoted string, and no
null-character will be stored.
Not that I agree with making it so easy to create a unterminated string...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13896