[Bug c++/29455] Issues with -Wchar-subscripts

preston at bannister dot us gcc-bugzilla@gcc.gnu.org
Thu Jan 8 11:56:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29455

Preston L Bannister <preston at bannister dot us> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |preston at bannister dot us

--- Comment #9 from Preston L Bannister <preston at bannister dot us> ---
(In reply to Hallvard B Furuseth from comment #7)
> > The warning in C++ is arguably bogus because the value of the
> > character '%' is known at compile-time, consequently the warning
> > is unwarranted (unless it really is negative).
> 
> unwarranted unless it _could_ be negative on some host.

Are there any hosts of this sort left? And for which GCC compiles?

The job of the compiler is to generate code for a specific machine. For a
character literal the compiler knows the exact value. If the value were
negative, a warning is justified. 

Generating a warning on code that is correct for the target is not useful. 

Likely the code will never be compiled on a platform where the warning is
correct.

Given almost no possibility the warning will ever be correctly identify a
problem, this is at least a very poor choice, and infinitely close to a bug. :)



More information about the Gcc-bugs mailing list