Closed rezaebrh closed 5 years ago
Compilers optimize assuming that bool has either 0 or 1 value. Any attempt to deal with broken bool is doomed https://godbolt.org/z/NqdmeB (optimized away on clang in all cases, on GCC in majority of cases).
Use UB sanitizer to find the corrupted bools in your project. Nothing could be done in lexical_cast
In case of forcing
bool
value to be something other than0
or1
,lexical_cast
won't throw any error. But the result is out ofbool
domain. This is where error might happen in case of re converting the converted value back tobool
. For more detail check boost::lexical_cast wrong outputIn our project, we use a function to convert and convert back some bool value to
std::string
and vise versa. When we are casting the value back tobool
, we facebad_lexical_cast
error. since the project is huge, we can't find out the rule breaking part but we hope some changes in boost will be helping us.