[cfe-dev] ios_base.h:96:24: runtime error: load of value 4294967221which is not a valid value for type 'std::_Ios_Fmtflags'

Jeffrey Walton noloader at gmail.com
Wed Jan 14 19:27:29 PST 2015


On Wed, Jan 14, 2015 at 9:40 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> 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'
>>
>> ...
>
> 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 Richard.

And sorry about the CFE-Dev mailing. It was intended for CFE-Users. I
was not paying enough attention to autocomplete.

Jeff



More information about the cfe-dev mailing list