[cfe-dev] ios_base.h:96:24: runtime error: load of value 4294967221which is not a valid value for type 'std::_Ios_Fmtflags'
Richard Smith
richard at metafoo.co.uk
Wed Jan 14 18:40:53 PST 2015
On Tue, Jan 6, 2015 at 7:41 PM, Jeffrey Walton <noloader at gmail.com> wrote:
> I know this has been discussed before:
>
> ios_base.h:96:24: runtime error: load of value 4294967221, which
> is not a valid value for type 'std::_Ios_Fmtflags'
>
> and
>
> ios_base.h:80:67: runtime error: load of value 4294967221, which
> is not a valid value for type 'std::_Ios_Fmtflags'
>
> Line 96 offender is the return:
>
> inline _Ios_Fmtflags&
> operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
> { return __a = __a & __b; }
>
> Line 80 offender is the return:
>
> inline _Ios_Fmtflags
> operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
> { return _Ios_Fmtflags(static_cast<int>(__a) &
> static_cast<int>(__b)); }
>
> For example,
> http://lists.cs.uiuc.edu/pipermail/llvmbugs/2013-December/031638.html,
> http://llvm.org/bugs/show_bug.cgi?id=18156 and
> https://www.marshut.net/suwhu/undefined-behavior-sanitizing-with-clang.html
> .
> But I can't seem to find the solution (only hits on the problem).
>
> Clang has been tagging it for a couple of years now. I'd like to clear
> the error on my MacBook (OS X 10.8.5, fully patched).
>
> What is the resolution?
>
The problem is in the definition of operator~:
inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
operator~(_Ios_Fmtflags __a)
{ return _Ios_Fmtflags(~static_cast<int>(__a)); }
Try changing that to
inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
operator~(_Ios_Fmtflags __a)
{ return __a ^ _Ios_Fmtflags(static_cast<int>(_S_ios_fmtflags_end) - 1); }
You could alternatively set up a suppression for this ubsan message (and be
careful not to build with -fstrict-enums); see
http://clang.llvm.org/docs/SanitizerSpecialCaseList.html.
Thanks in advance.
>
> *****
>
> $ /usr/local/bin/clang++ -v
> clang version 3.5.0 (tags/RELEASE_350/final)
> Target: x86_64-apple-darwin12.5.0
> Thread model: posix
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150114/be4c8e2b/attachment.html>
More information about the cfe-dev
mailing list