[v3] system_error, round one
Benjamin Kosnik
bkoz@redhat.com
Tue May 15 17:28:00 GMT 2007
>> + const char*
>> + system_error::what() const throw()
>> + {
>> + // XXX logic seems wrong as written in draft, need to
>> + // concatenate message?
>> + string __s = runtime_error::what();
>> + try
>> + {
>> + if (this->code())
>> + {
>> + if (!__s.empty())
>> + __s += " : ";
>> + __s += this->code().message();
>> + }
>> + }
>> + catch (...) { }
>> + return __s.c_str();
>> + }
>
> Besides the dangling .c_str, you have an additional problem here: the
> construction of __s can throw. What's wrong with the suggested
> implementation in N2241
currently, there is an embedded string object (which is not mandated in
the standard), but it is private. We will have to make it protected and
mutable in order to be used in what, which is marked const.
It seems like a warning flag that we'd have to change around existing
exception designs for this class, although it is certainly possible.
-benjamin
More information about the Libstdc++
mailing list