Why would the second case not be possible?<div>What i have in mind by example:</div><div><br></div><div>```</div><div>void definitly_throws() { // should be marked noexcept(false), maybe as configuration option</div><div><span style="white-space: pre-wrap"> if (some_condition())</span></div><div><span style="white-space: pre-wrap"> </span><span style="white-space: pre-wrap;"> throw std::logic_error{"Reasons"};</span></div><div><span style="white-space: pre-wrap"> else</span></div><div><span style="white-space: pre-wrap"> </span><span style="white-space: pre-wrap;"> // do unproblematic stuff</span></div><div>}</div><div><br></div><div>void probably_throws() { // this needs more analysis then AST matching so leave it as is</div><div><span style="white-space: pre-wrap"> try {</span></div><div><span style="white-space: pre-wrap"> </span><span style="white-space: pre-wrap;"> // operation</span></div><div><span style="white-space: pre-wrap"> </span><span style="white-space: pre-wrap;"> if (op_failed())</span></div><div><span style="white-space: pre-wrap"> </span><span style="white-space: pre-wrap;"> </span><span style="white-space: pre-wrap;"> throw std::runtime_error{"Operation failed"};</span></div><div><span style="white-space: pre-wrap"> } </span></div><div><span style="white-space: pre-wrap"> catch (std::runtime_error& e)</span></div><div><span style="white-space: pre-wrap"> { /* handle */ }</span></div><div>}</div><div>```</div><div><br></div><div>The second one can be noexcept if the operation will not throw. It is not noexcept if operation is not noexcept.</div><div>What did I miss?</div><div><br></div><div>The deeper analysis will not happen if the analyser does not see all code, but if it can shouldnt there the possibility to decide? Maybe it has bad complexity and is therefor not practical. But maybe in some cases there can be insight gained?</div><div><br></div><div>
Am Do, 16. Mär, 2017 um 11:25 schrieb Daniel Marjamäki <Daniel.Marjamaki@evidente.se>:<br>
<blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (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;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:8.5in 11.0in;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">As far as I see:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">- a function calling only `noexcept` operations that does not throw can be marked noexcept<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">possible<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">- a function that has a `throw` statement not within a `try/catch` block can be marked noexcept(false)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Not possible<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">- a function calling a function that is not marked noexcept can not be marked noexcept<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> but it could be noexecpt with deeper analysis on what exception could be thrown and what exceptions are handled<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">not possible<o:p></o:p></span></p>
</div></blockquote><br>
</div>