[cfe-dev] [libc++] Better std::string exception messages

Shoaib Meenai via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 30 09:46:29 PST 2020


Forwarding this to libcxx-dev (moving cfe-dev to BCC)

From: cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of cfe-dev <cfe-dev at lists.llvm.org>
Reply-To: LANDER Tim <tim.lander at hexagon.com>
Date: Wednesday, January 29, 2020 at 11:11 PM
To: cfe-dev <cfe-dev at lists.llvm.org>
Subject: [cfe-dev] [libc++] Better std::string exception messages

Not sure if this is the right place to post stuff like this, so feel free to redirect me.

I’ve noticed that libc++ std::string exception messages are very basic compared to other standard libraries (eg libstdc++), with (as far as I can tell) everything throwing the exception message “basic string”.
Location where this message comes from: https://github.com/llvm-mirror/libcxx/blob/da6e915c73f231074dc88f8a952a8273da0ca06b/include/string#L609-L616

Example code:
int main(int argc, char** argv) {
  try {
    std::string().at(1);
  } catch (const std::out_of_range &e) {
    printf("e.what is: %s\n", e.what());
  }
}

-stdlib=libc++<https://urldefense.proofpoint.com/v2/url?u=http-3A__coliru.stacked-2Dcrooked.com_a_2c7b3070dd82eb7c&d=DwMFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=BQjWuwNiRKHDRIHl0U_yBVHj_I2EzuHiHoKqEabE7RI&s=LUtyrNUc-vQOo6HqyTqtrdgxIpsJpN4F7tIkuPoxfFw&e=>: e.what is: basic_string
-stdlib=libstdc++<https://urldefense.proofpoint.com/v2/url?u=http-3A__coliru.stacked-2Dcrooked.com_a_36d1729322573a69&d=DwMFAg&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=BQjWuwNiRKHDRIHl0U_yBVHj_I2EzuHiHoKqEabE7RI&s=hxBnifC3ZaXT43bW_6bQ9Z2uLAJHS8sXxf1jHqkU7NI&e=>: e.what is: basic_string::at: __n (which is 1) >= this->size() (which is 0)

Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200130/451522fb/attachment-0001.html>


More information about the cfe-dev mailing list