<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 with C++11 uniform initialization of an array of type with explicit default constructor"
href="https://llvm.org/bugs/show_bug.cgi?id=27052">27052</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Error with C++11 uniform initialization of an array of type with explicit default constructor
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</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>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mosra@centrum.cz
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I am getting an error when compiling the following snippet:
struct Explicit {
explicit Explicit() {}
};
struct A {
A(): _a{} {}
Explicit _a[5];
};
int main() {}
Clang 3.7.1 complains that `error: chosen constructor is explicit in
copy-initialization`, both GCC 5.3 and MSVC 2015 compile fine. The behavior
differs when I make the following changes:
- If I remove the `explicit` keyword, it compiles fine (of course).
- If I make the `_a` member a non-array, it compiles fine.
- If I change `_a{}` to the C++03-style `_a()`, it compiles fine.
- If I change `_a{}` to `_a{Explicit{}, Explicit{}, Explicit{}, Explicit{},
Explicit{}}`, it compiles fine.
- If I change the constructor to `explicit Explicit() = default;`, it compiles
fine.
The problem is not just when using constructor initializer lists, but also when
initializing the array as a variable like this:
Explicit b[5]{};
This behavior seems rather arbitrary to me and since the "old" C++03-style
works okay, I think it should have the same behavior in C++11.
This probably affects also older versions, didn't have a chance to test.</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>