[LLVMbugs] [Bug 11764] New: decltype(MyClass()) doesn't work as a trailing return type
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jan 14 06:21:47 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=11764
Bug #: 11764
Summary: decltype(MyClass()) doesn't work as a trailing return
type
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jyasskin at google.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Given the following program:
#include <typeinfo>
#include <iostream>
#include <vector>
template<typename T>
struct array_ref {
array_ref(const std::vector<T>& v) {}
};
template<typename T>
auto make_array_ref(const T& t) -> decltype(array_ref<int>(t)) {
return array_ref<int>(t);
}
template<typename T>
void WriteType(T t) {
std::cout << typeid(decltype(array_ref<int>(t))).name() << '\n';
}
int main() {
std::vector<int> v;
WriteType(v);
make_array_ref(v);
}
-----------
clang++ -std=c++11 gives the following error:
test.cc:12:12: error: no viable conversion from 'array_ref<int>' to
'decltype(array_ref<int>(t))'
return array_ref<int>(t);
^~~~~~~~~~~~~~~~~
1 error generated.
The lack of 'aka' is bug 10405, but I believe the code should compile as-is. It
does with gcc-4.6, and the decltype() expression is exactly the same as the
returned expression. Further, when I comment out make_array_ref(), clang and
gcc print "9array_refIiE" (array_ref<int>), which is the type of the return
value.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list