<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - default member initialization and noexcept problems"
href="https://bugs.llvm.org/show_bug.cgi?id=33736">33736</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>default member initialization and noexcept problems
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>4.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>joe.sylve@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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.
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.
#include <memory>
struct A {
A() noexcept = default;
A(const A&) noexcept = default;
std::shared_ptr<int> _a {};
};
int main() {
return 0;
}
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.
The error I'm getting is as follows:
<source>:4:5: error: default member initializer for '_a' needed within
definition of enclosing class 'A' outside of member functions
A() noexcept = default;
^
/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
template <class _Tp, bool = is_class<_Tp>::value>
^
/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
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract : public
__libcpp_abstract<_Tp> {};
^~~~~~~~~~~~~~~~~~~~~~
/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
!is_abstract<_T2>::value> {};
^
/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
typename enable_if<is_convertible<_Yp*,
element_type*>::value, __nat>::type = __nat())
^
/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]
class _LIBCPP_TEMPLATE_VIS shared_ptr
^
<source>:7:26: note: default member initializer declared here
std::shared_ptr<int> _a {};</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>