<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 11, 2015 at 3:45 PM, Louis Dionne <span dir="ltr"><<a href="mailto:ldionne.2@gmail.com" target="_blank">ldionne.2@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">The faulty code was mine. With the `pair` example, it is clear that all those `is_default_constructible<T>` are instantiated even when the default constructor is not. I think my intention when writing `Dummy && is_default_constructible<_Tp>::value` was to delay the instantiation of `is_default_constructible<_Tp>` as a compile-time optimization (which it fails to do), but not for correctness purposes.<br>
<br>
However, looking at <a href="http://en.cppreference.com/w/cpp/types/is_default_constructible" target="_blank">http://en.cppreference.com/w/cpp/types/is_default_constructible</a> and then <a href="http://en.cppreference.com/w/cpp/concept/DefaultConstructible" target="_blank">http://en.cppreference.com/w/cpp/concept/DefaultConstructible</a>, I am unsure whether instantiating `is_default_constructible<_Tp>` should cause a hard error at all. If instantiating the default constructor in the expression<br>
<br>
<br>
  _Tp x{}<br>
<br>
causes a compile-time error, should `is_default_constructible<_Tp>::value` be false or trigger a compile-time error?<br>
<br>
Summary: At a glance, the fix seems correct in that it will properly delay the instantiation of the `is_default_constructible<_Tp>`s. However, is there a bug in `is_default_constructible`?<br></blockquote><div><br></div><div>The issue is that it results in instantiation of decltype( _Tp()), and because the selected constructor is constexpr, it is eagerly instantiated (and that instantiation fails) even though it is not actually invoked here. (That in turn is necessary to support ridiculous things like "decltype(char{_Tp().n})" whose validity depends on whether the result of constant-evaluating _Tp().n gives a value that fits within a 'char'.)</div><div><br></div><div>It's not yet completely clear whether Clang's (and GCC's) behavior is right here; there's an active core issue on how to handle this case.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<a href="http://reviews.llvm.org/D7569" target="_blank">http://reviews.llvm.org/D7569</a><br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
<br>
<br>
</blockquote></div><br></div></div>