On Tue, May 14, 2013 at 4:30 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On May 14, 2013, at 3:29 PM, Alireza Moshtaghi <<a href="mailto:Alireza.Moshtaghi@synopsys.com">Alireza.Moshtaghi@synopsys.com</a>> wrote:<br>
> g++ accepts this code ,  but clang generates:<br>
>   error1.cpp:5:12:<br>
>   error: addition of default argument on redeclaration makes this<br>
>          constructor a default constructor<br>
> “<br>
> struct XX {<br>
>     int a;<br>
>     XX(int);<br>
> };<br>
> XX::XX(int c = 5) : a(c) { }<br>
> “<br>
> Question: where does this requirement come from ?<br>
<br>
</div>DR1344 is a defect report reported to the C++ standards committee:<br>
  <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1344" target="_blank">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1344</a><br>
<br>
We expect the committee to make some sort of modification here and<br>
have pre-emptively locked things down to reserve more flexibility to<br>
respond to whatever the committee does.<br>
<br>
The idea is that the presence of certain special members affects core<br>
properties of a class type, like whether it's POD or trivially copyable.<br>
Deciding these properties should not require whole-program knowledge;<br>
it's important for us to be able to deduce them just from the class definition.<br>
The really problematic case is turning a "normal" constructor into a copy<br>
or move constructor by adding default arguments, but IIRC introducing a<br>
default constructor was also problematic.<br>
<br>
The fix is that you should put the default argument in the initial declaration<br>
of the constructor.<br></blockquote><div><br></div><div>This was last discussed by WG21 at the Bloomington meeting. Notes from there:</div><div><br></div><div>  "Consensus: Make this ill-formed as suggested in the write-up. Core issue 1344. Priority 0, Doug drafting."</div>
<div><br></div><div>So CWG has agreed (in principle) that this should be ill-formed.</div></div>