[cfe-dev] -fsanitize=enum false positive with ˜ios::failbit ?

Richard Smith richard at metafoo.co.uk
Thu Feb 28 16:57:37 PST 2013


On Thu, Feb 28, 2013 at 12:40 PM, Brad King <brad.king at kitware.com> wrote:

> On 02/28/2013 03:33 PM, Joe Groff wrote:
> > On Thu, Feb 28, 2013 at 11:36 AM, Sean McBride wrote:
> >> The C++03 standard does "~ios::failbit" in 27.6.1.3/22
> >
> > Enum values are only defined for the number of bits needed to
> > represent the type's member values, so if 'x' is a defined iostate
> > value, then 'x & ~ios::failbit' results in a valid iostate value,
> > but ~ios::failbit is not itself a valid iostate value.
>
> The question is actually about the expression from C++03 27.6.1.3/22:
>
>  cin.clear(cin.rdstate() & ~ios::failbit);
>
> C++03 27.4.2 defines iostate and failbit:
>
>  typedef T2 iostate;
>  ...
>  static const iostate failbit;
>
> C++03 27.4.2.1.3 requires iostate to be a bitmask type:
>
>  The type iostate is a bitmask type (17.3.2.1.2)
>
> C++03 17.3.2.1.2 requires bitmask types to support ~:
>
>  bitmask operator ~(bitmask X)


Sure, but UBSan is telling you that it found a bug in libstdc++'s
implementation of operator~ for iostate.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130228/f7a2a393/attachment.html>


More information about the cfe-dev mailing list