<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 --- - Deprecated (legacy) string literal conversion to 'char *' causes strange overloading resolution"
href="https://llvm.org/bugs/show_bug.cgi?id=28050">28050</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Deprecated (legacy) string literal conversion to 'char *' causes strange overloading resolution
</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>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>mO_Okar@mail.ru
</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>The conversion from string literal to 'char *' makes the compiler to choose
initialization through the move constructor. See the following example:
$ cat test.cpp
class A {
public:
A(char *s) {}
A(A &&) = delete;
};
void test() { A a("OK"); }
$ clang -cc1 -std=c++11 -fsyntax-only test.cpp
test.cpp:7:17: error: call to deleted constructor of 'A'
void test() { A a("OK"); }
^ ~~~~
test.cpp:4:3: note: 'A' has been explicitly marked deleted here
A(A &&) = delete;
^
1 error generated.
If we remove the '= delete' part, we'll get the following AST for function
'test':
`-FunctionDecl {{.*}} test 'void (void)'
`-CompoundStmt {{.*}}
`-DeclStmt {{.*}}
`-VarDecl {{.*}} a 'class A' callinit
`-CXXConstructExpr {{.*}} 'class A' 'void (class A &&)' elidable
`-MaterializeTemporaryExpr {{.*}} 'class A' xvalue
`-CXXConstructExpr {{.*}} 'class A' 'void (char *)'
`-ImplicitCastExpr {{.*}} 'char *' <NoOp>
`-ImplicitCastExpr {{.*}} 'const char *' <ArrayToPointerDecay>
`-StringLiteral {{.*}} 'const char [3]' lvalue "OK"
However, other standard conversions (like numeric promotion and even
qualification adjustment) are not affected.
Alexander Makarov,
Intel Software Engineer</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>