diff --git a/src/variant.cpp b/src/variant.cpp index 7b73771..542ee66 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -431,7 +431,14 @@ bool variant::as_bool()const switch( get_type() ) { case string_type: - return **reinterpret_cast(this) == "true"; + { + const string& s = **reinterpret_cast(this); + if( s == "true" ) + return true; + if( s == "false" ) + return false; + FC_THROW_EXCEPTION( bad_cast_exception, "Cannot convert string to bool (only \"true\" or \"false\" can be converted)" ); + } case double_type: return *reinterpret_cast(this) != 0.0; case int64_type: