This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] system_error, round one


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?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]