<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Forwarding this to libcxx-dev (moving cfe-dev to BCC)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">cfe-dev <cfe-dev-bounces@lists.llvm.org> on behalf of cfe-dev <cfe-dev@lists.llvm.org><br>
<b>Reply-To: </b>LANDER Tim <tim.lander@hexagon.com><br>
<b>Date: </b>Wednesday, January 29, 2020 at 11:11 PM<br>
<b>To: </b>cfe-dev <cfe-dev@lists.llvm.org><br>
<b>Subject: </b>[cfe-dev] [libc++] Better std::string exception messages<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Not sure if this is the right place to post stuff like this, so feel free to redirect me.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">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”.<o:p></o:p></p>
<p class="MsoNormal">Location where this message comes from: <a href="https://github.com/llvm-mirror/libcxx/blob/da6e915c73f231074dc88f8a952a8273da0ca06b/include/string#L609-L616">
https://github.com/llvm-mirror/libcxx/blob/da6e915c73f231074dc88f8a952a8273da0ca06b/include/string#L609-L616</a><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Example code:<o:p></o:p></p>
<p class="MsoNormal">int main(int argc, char** argv) {<o:p></o:p></p>
<p class="MsoNormal">  try {<o:p></o:p></p>
<p class="MsoNormal">    std::string().at(1);<o:p></o:p></p>
<p class="MsoNormal">  } catch (const std::out_of_range &e) {<o:p></o:p></p>
<p class="MsoNormal">    printf("e.what is: %s\n", e.what());<o:p></o:p></p>
<p class="MsoNormal">  }<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><a href="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=">-stdlib=libc++</a>:
 e.what is: basic_string<o:p></o:p></p>
<p class="MsoNormal"><a href="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=">-stdlib=libstdc++</a>:
 e.what is: basic_string::at: __n (which is 1) >= this->size() (which is 0)<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Tim<o:p></o:p></p>
</div>
</body>
</html>