The assignment of a value to a variable of type
std::string
can only crash if the value passed is disguised as a type that it isn't and contains value that doesn't fit the expectation tied to that type.
In this case, you are passing variables of type
OString
directly, implying that the type
OString
has an implicit conversion operator to a type that can be assigned to a
std::string
variable. Most likely this type is
const char*
. Check the implementation of the following operator:
OString::operator const char*() const
The actual function may be missing a const or two, but it must exist, or the assignment wouldn't even compile! In the implementation code, check what is returned.
There are at least two things that can go wrong in this code:
1. Returning an incorrect value, possibly by type-casting something to
const char*
2. Returning a pointer that wasn't correctly initialized or assigned; this may also be due to an error in the code for the assignment operator.
If these hints don't help you identify the bug, show us the code of the relevant
OString
operators (assignment and conversion operators, mostly).