<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 8, 2014 at 1:21 AM, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@bugseng.com" target="_blank">abramo.bagnara@bugseng.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
template<typename T> void f2(T a, T b = T()) { }<br>
<br>
void m() {<br>
f2(10);<br>
f2(10);<br>
f2(10);<br>
f2(10);<br>
}<br>
<br>
Checking the AST generated for the source above I've seen that the<br>
default argument expression is not instantiated in specialization of<br>
function f2, but instead such transformation is done (and redone) in the<br>
calls to f2.<br>
<br>
In this way:<br>
<br>
- we have dependent expr in the declaration of fully instantiated<br>
functions (that is unexpected, at least for me)<br>
<br>
- we have multiple copies of the same expression (one for each call)<br>
<br>
Is this deliberate?</blockquote><div><br></div><div>It's deliberate that we delay instantiating the exception specification until it's used; that's what the C++ standard says should happen. As far as I know, it's not deliberate that we instantiate the default argument each time it's used; that seems like a bug.</div></div></div></div>