<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 --- - Overload resolution works when function reference type is used as lhs of assignment but not a cast-expression" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23811&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=Oq1wynzjiBmuJx8FJQtpS7jv87uXb1XXwVIVyqJIQ8I&s=RNyMLWvcAAJ9LYpO7ZLd0d3JiXGiC65SAJwzqmIz8Y0&e=">23811</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Overload resolution works when function reference type is used as lhs of assignment but not a cast-expression
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.6
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>andrey.vul@gmail.com
</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>The following code tests [over.over]/1.2 and [over.over]/1.6.
Clang resolves the address of the overloaded function in the first case but not
the second case.
SOURCE: cat /tmp/a.cc
template <class T> T f(T x) {
return x + 1;
}
int main() {
typedef int (&&fp1)(int);
fp1&& p10 = f; // ok
fp1&& p11 = static_cast<fp1&&>(f); // fail
}
INVOCATION: clang++ -std=c++11 -v
clang version 3.6.1 (tags/RELEASE_361/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
Selected GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2
"/usr/bin/x86_64-pc-linux-gnu-clang-3.6.1" -cc1 -triple x86_64-pc-linux-gnu
-emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name a.cc
-mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -target-linker-version 2.25 -v -dwarf-column-info
-resource-dir /usr/bin/../lib/clang/3.6.1 -internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4 -internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/x86_64-pc-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/bin/../lib/clang/3.6.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro
-fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 150
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/a-810097.o -x c++ a.cc
clang -cc1 version 3.6.1 based upon LLVM 3.6.1 default target
x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/x86_64-pc-linux-gnu
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/backward
/usr/bin/../lib/clang/3.6.1/include
/usr/include
End of search list.
a.cc:8:14: error: address of overloaded function 'f' cannot be static_cast to
type 'fp1 &&'
fp1&& p11 = static_cast<fp1&&>(f);
^~~~~~~~~~~~~~~~~~~~~
a.cc:1:22: note: candidate function
template <class T> T f(T x) {
^
1 error generated.</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>