<html>
<head>
<base href="https://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 --- - "error: default initialization of an object of const type 'const Z' requires a user-provided default constructor" even when no constructor needed."
href="https://llvm.org/bugs/show_bug.cgi?id=23381">23381</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>"error: default initialization of an object of const type 'const Z' requires a user-provided default constructor" even when no constructor needed.
</td>
</tr>
<tr>
<th>Product</th>
<td>compiler-rt
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>compiler-rt
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>daniel.black@openquery.com.au
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>"error: default initialization of an object of const type 'const Z' requires a
user-provided default constructor" even when no constructor needed.
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#253</a>
$ cat > /tmp/x.cc
struct Z {
// no data members
operator int() const { return 0; }
};
void f() {
const Z z1; // ill-formed: no initializer
const Z z2 = { }; // well-formed
}
$ clang++ -c /tmp/x.cc
/tmp/x.cc:7:17: error: default initialization of an object of const type 'const
Z' requires a user-provided default constructor
const Z z1; // ill-formed: no initializer
^
1 error generated.
g++ compiles without error
clang++ --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
g++ (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</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>