On Thu, Feb 28, 2013 at 12:40 PM, Brad King <span dir="ltr"><<a href="mailto:brad.king@kitware.com" target="_blank">brad.king@kitware.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 02/28/2013 03:33 PM, Joe Groff wrote:<br>
<div class="im">> On Thu, Feb 28, 2013 at 11:36 AM, Sean McBride wrote:<br>
>> The C++03 standard does "~ios::failbit" in <a href="http://27.6.1.3/22" target="_blank">27.6.1.3/22</a><br>
><br>
</div><div class="im">> Enum values are only defined for the number of bits needed to<br>
> represent the type's member values, so if 'x' is a defined iostate<br>
> value, then 'x & ~ios::failbit' results in a valid iostate value,<br>
> but ~ios::failbit is not itself a valid iostate value.<br>
<br>
</div>The question is actually about the expression from C++03 <a href="http://27.6.1.3/22" target="_blank">27.6.1.3/22</a>:<br>
<br>
 cin.clear(cin.rdstate() & ~ios::failbit);<br>
<br>
C++03 27.4.2 defines iostate and failbit:<br>
<br>
 typedef T2 iostate;<br>
 ...<br>
 static const iostate failbit;<br>
<br>
C++03 27.4.2.1.3 requires iostate to be a bitmask type:<br>
<br>
 The type iostate is a bitmask type (17.3.2.1.2)<br>
<br>
C++03 17.3.2.1.2 requires bitmask types to support ~:<br>
<br>
 bitmask operator ~(bitmask X)</blockquote><div><br></div><div>Sure, but UBSan is telling you that it found a bug in libstdc++'s implementation of operator~ for iostate. </div></div>