This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: avoid warnings on array[CHAR_CONSTANT]


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]