<html>
<head>
<base href="http://llvm.org/bugs/" />
</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 --- - Class without default constructor, but with destructor is not trivially constructible"
href="http://llvm.org/bugs/show_bug.cgi?id=17813">17813</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Class without default constructor, but with destructor is not trivially constructible
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jonathan.sauer@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code does not compile with clang r193986:
struct Foo {
~Foo();
};
static_assert(__is_trivially_constructible(Foo), "");
static_assert(__has_trivial_constructor(Foo), "");
This results in:
% ~/LLVM/build/Release+Asserts/bin/clang -c -std=c++11 clang.cpp
clang.cpp:5:1: error: static_assert failed ""
static_assert(__is_trivially_constructible(Foo), "");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Removing the destructor makes the code compile.
This looks like an inconsistency between __is_trivially_constructible and
__has_trivial_constructor, the former of which are used by libc++'s
std::is_trivially_constructible type trait (the latter is only used if the
former is not available).
Also __is_trivially_constructible is influenced by the existence of a
destructor, despite §12.1p5 not mentioning destructors:
| A default constructor is trivial if it is not user-provided and if:
| — its class has no virtual functions (10.3) and no virtual base classes
| (10.1), and
| — no non-static data member of its class has a brace-or-equal-initializer,
| and
| — all the direct base classes of its class have trivial default constructors,
| and
| — for all the non-static data members of its class that are of class type
| (or array thereof), each such class has a trivial default constructor.</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>