This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: avoid warnings on array[CHAR_CONSTANT]
- From: Richard Henderson <rth at redhat dot com>
- To: Eddie Kohler <kohler at icir dot org>
- Cc: Mike Stump <mrs at apple dot com>, gcc-patches at gcc dot gnu dot org, Jonathan Lennox <lennox at cs dot columbia dot edu>
- Date: Thu, 12 Jun 2003 09:44:07 -0700
- Subject: Re: PATCH: avoid warnings on array[CHAR_CONSTANT]
- References: <20030611230906.GA18326@redhat.com> <200306112346.h5BNksi8020584@coyote.icir.org>
On Wed, Jun 11, 2003 at 04:46:54PM -0700, Eddie Kohler wrote:
> - The idiom compiles without warning under C.
Which would seem to be an argument that the C front end
is buggy that it does NOT give the warning, since the
risks are identical.
> - The alternatives are ugly:
> "a[ (unsigned char)'A' ]"
> (or, God forbid, "a[ static_cast<unsigned char>('A') ]")
> "a[ (uint8_t)'A' ]"
> or worse, incorrect:
> "a[ (int)'A' ] /* ASCII-centric programmer! */"
But one of these IS required if you want univeral correctness.
Perhaps you should propose to the relevant standards bodies a
syntax extension such as U'A' which would produce an unsigned
character constant.
Really, I would be more receptive to a -Wno-character-index
switch if you're sure that all of the remaining cases are valid
for the character set you care about.
r~