<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 --- - no matching constructor for initialization of 'string' (aka 'basic_string<char>')" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23657&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=43zoEelYz43zx9IPQKWBZsiXyFP6V7Sm9Oh8MZlILZI&s=zcq_J-rXdVJkwYskxdkDjTAW3YTXywpDGbDnVZJztAA&e=">23657</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>no matching constructor for initialization of 'string' (aka 'basic_string<char>')
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</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>apyszczuk@gmail.com
</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>#include <iostream>
#include <string>
using namespace std;
class Foo {
public:
operator string() const { return n; }
string n {"foo"};
};
int main (int argc, char** argv) {
string s {Foo{}}; // Error
// string s (Foo{}); // Ok
cout << s << endl;
return 0;
}
main.cpp:14:12: error: no matching constructor for initialization of 'string'
(aka 'basic_string<char>')
string s {Foo{}}; // Error
^ ~~~~~~~
I asked about this on stackoverflow (link added below) and someone replied that
it possibly can be a clang bug, so I posted it here. Is this a bug? gcc 4.8.3
compiles it.
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__stackoverflow.com_questions_30461583_no-2Dmatching-2Dconstructor-2Dfor-2Dinitialization-2Dof-2Dstring-2Daka-2Dbasic-2Dstringchar_30461995-2330461995&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=43zoEelYz43zx9IPQKWBZsiXyFP6V7Sm9Oh8MZlILZI&s=_bWOKaOFPmlysPfL1b53DHmv952HHenp6PlcZh4o7gQ&e=">http://stackoverflow.com/questions/30461583/no-matching-constructor-for-initialization-of-string-aka-basic-stringchar/30461995#30461995</a>
Thanks</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>