[v3] system_error, round one

Peter Dimov pdimov@mmltd.net
Tue May 15 13:02:00 GMT 2007


Benjamin Kosnik wrote:

> +  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? 



More information about the Libstdc++ mailing list