<div dir="ltr"><div>I'm seeing an error that is similar to the question raised at <a href="https://stackoverflow.com/questions/43819314">https://stackoverflow.com/questions/43819314</a>.  That question seems to not have any consensus as to what the problem may be.  </div><div><br></div><div>I would appreciate if someone could shed some light on my issue and let me know if this is a known compiler bug or if clang is working as intended.</div><div><br></div><div>The following code produces a compile-time error in clang++ 4.0.0 and later, but works fine in gcc as well as previous versions of clang.</div><div><br></div><div>#include <memory></div><div><br></div><div>struct A {</div><div>    A() noexcept = default;</div><div>    A(const A&) noexcept = default;</div><div><br></div><div>    std::shared_ptr<int> _a {};</div><div>};</div><div><br></div><div>int main() {</div><div>    return 0;</div><div>}</div><div><br></div><div>It's worth noting that if I remove the copy constructor, this compiles fine.  If I remove the noexcept qualification from the default constructor it also compiles fine.</div><div><br></div><div>The error I'm getting is as follows:</div><div><br></div><div><source>:4:5: error: default member initializer for '_a' needed within definition of enclosing class 'A' outside of member functions</div><div>    A() noexcept = default;</div><div>    ^</div><div>/opt/compiler-explorer/clang-4.0.0/bin/../include/c++/v1/type_traits:1306:29: note: in instantiation of template class 'std::__1::is_class<int *>' requested here</div><div>template <class _Tp, bool = is_class<_Tp>::value></div><div>                            ^</div><div>/opt/compiler-explorer/clang-4.0.0/bin/../include/c++/v1/type_traits:1311:71: note: in instantiation of default argument for '__libcpp_abstract<int *>' required here</div><div>template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract : public __libcpp_abstract<_Tp> {};</div><div>                                                                      ^~~~~~~~~~~~~~~~~~~~~~</div><div>/opt/compiler-explorer/clang-4.0.0/bin/../include/c++/v1/type_traits:1384:39: note: in instantiation of template class 'std::__1::is_abstract<int *>' requested here</div><div>                                     !is_abstract<_T2>::value> {};</div><div>                                      ^</div><div>/opt/compiler-explorer/clang-4.0.0/bin/../include/c++/v1/memory:3918:39: note: in instantiation of template class 'std::__1::is_convertible<int *, int *>' requested here</div><div>                   typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat())</div><div>                                      ^</div><div>/opt/compiler-explorer/clang-4.0.0/bin/../include/c++/v1/memory:3883:28: note: while substituting deduced template arguments into function template 'shared_ptr' [with _Yp = int]</div><div>class _LIBCPP_TEMPLATE_VIS shared_ptr</div><div>                           ^</div><div><source>:7:26: note: default member initializer declared here</div><div>    std::shared_ptr<int> _a {};</div></div>