<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 6, 2015 at 7:41 PM, Jeffrey Walton <span dir="ltr"><<a href="mailto:noloader@gmail.com" target="_blank">noloader@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I know this has been discussed before:<br>
<br>
ios_base.h:96:24: runtime error: load of value 4294967221, which<br>
is not a valid value for type 'std::_Ios_Fmtflags'<br>
<br>
and<br>
<br>
ios_base.h:80:67: runtime error: load of value 4294967221, which<br>
is not a valid value for type 'std::_Ios_Fmtflags'<br>
<br>
Line 96 offender is the return:<br>
<br>
inline _Ios_Fmtflags&<br>
operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)<br>
{ return __a = __a & __b; }<br>
<br>
Line 80 offender is the return:<br>
<br>
inline _Ios_Fmtflags<br>
operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)<br>
{ return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }<br>
<br>
For example, <a href="http://lists.cs.uiuc.edu/pipermail/llvmbugs/2013-December/031638.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmbugs/2013-December/031638.html</a>,<br>
<a href="http://llvm.org/bugs/show_bug.cgi?id=18156" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=18156</a> and<br>
<a href="https://www.marshut.net/suwhu/undefined-behavior-sanitizing-with-clang.html" target="_blank">https://www.marshut.net/suwhu/undefined-behavior-sanitizing-with-clang.html</a>.<br>
But I can't seem to find the solution (only hits on the problem).<br>
<br>
Clang has been tagging it for a couple of years now. I'd like to clear<br>
the error on my MacBook (OS X 10.8.5, fully patched).<br>
<br>
What is the resolution?<br></blockquote><div><br></div><div>The problem is in the definition of operator~:</div><div><br></div><div><div> inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags</div><div> operator~(_Ios_Fmtflags __a)</div><div> { return _Ios_Fmtflags(~static_cast<int>(__a)); }</div></div><div><br></div><div>Try changing that to</div><div><div><br></div><div> inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags</div><div> operator~(_Ios_Fmtflags __a)</div><div> { return __a ^ _Ios_Fmtflags(static_cast<int>(_S_ios_fmtflags_end) - 1); }</div></div><div><br></div><div>You could alternatively set up a suppression for this ubsan message (and be careful not to build with -fstrict-enums); see <a href="http://clang.llvm.org/docs/SanitizerSpecialCaseList.html">http://clang.llvm.org/docs/SanitizerSpecialCaseList.html</a>.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thanks in advance.<br>
<br>
*****<br>
<br>
$ /usr/local/bin/clang++ -v<br>
clang version 3.5.0 (tags/RELEASE_350/final)<br>
Target: x86_64-apple-darwin12.5.0<br>
Thread model: posix<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>