[llvm-bugs] [Bug 28050] New: Deprecated (legacy) string literal conversion to 'char *' causes strange overloading resolution
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 8 04:45:53 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28050
Bug ID: 28050
Summary: Deprecated (legacy) string literal conversion to 'char
*' causes strange overloading resolution
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: mO_Okar at mail.ru
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160608/de70d1eb/attachment-0001.html>
More information about the llvm-bugs
mailing list