[PATCH] D58896: Suppress -Wchar-subscripts if the index is a literal char

Stephan Bergmann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 00:51:14 PST 2019


sberg added a comment.

In D58896#1738288 <https://reviews.llvm.org/D58896#1738288>, @aaron.ballman wrote:

> In D58896#1738263 <https://reviews.llvm.org/D58896#1738263>, @sberg wrote:
>
> > In D58896#1737242 <https://reviews.llvm.org/D58896#1737242>, @edward-jones wrote:
> >
> > > In D58896#1737113 <https://reviews.llvm.org/D58896#1737113>, @sberg wrote:
> > >
> > > > But how about literals like `'\x80'` where the promoted value depends on whether plain `char` is signed or unsigned?
> > >
> > >
> > > If 'char' is signed and index into an array then this will typically trigger an `-Warray-bounds` warning because it references before the start of the array.
> >
> >
> > My thought was more that it might be useful as a kind of portability warning.
>
>
> I'm not opposed to the warning per-se, but do you have evidence that the situation occurs in real-world code?


No.  (My original comment was driven by my, potentially false, assumption that this warning was originally, at least in part, meant to flag portability issues---along the lines of: why else would the warning trigger at all when `char` is unsigned.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58896/new/

https://reviews.llvm.org/D58896





More information about the cfe-commits mailing list