[LLVMbugs] [Bug 19917] New: static_cast to rvalue reference rejected although reference binding via conversion function works
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jun 1 19:51:51 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19917
Bug ID: 19917
Summary: static_cast to rvalue reference rejected although
reference binding via conversion function works
Product: clang
Version: 3.4
Hardware: Other
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: hstong at ca.ibm.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
The declaration in foo() appears to satisfy the requirements in N3290 subclause
5.2.9 [expr.static.cast] paragraph 4 for the static_cast in bar() to be valid.
Clang does not seem to like the static_cast; GCC does.
### SOURCE:> cat rvRefStaticCastViaUDC.cc
struct A { };
struct B {
operator A();
} bObj;
void foo() { A &&a(bObj); }
void bar() { static_cast<A &&>(bObj); }
Return: 0x00:0
### COMPILER OUTPUT AND INVOCATION:> clang++ -std=c++11 -c
rvRefStaticCastViaUDC.cc
rvRefStaticCastViaUDC.cc:9:14: error: cannot cast from lvalue of type 'struct
B' to rvalue reference type 'A &&'; types are not compatible
void bar() { static_cast<A &&>(bObj); }
^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Return: 0x01:1
### EXPECTED OUTPUT:> g++-4.8 -std=c++11 -c rvRefStaticCastViaUDC.cc
Return: 0x00:0
### VERSION INFO:> clang++ -v
clang version 3.4 (tags/RELEASE_34/final)
Target: powerpc64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.4
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Selected GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Return: 0x00:0
--
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/20140602/949a4331/attachment.html>
More information about the llvm-bugs
mailing list