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



+  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


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