[LLVMbugs] [Bug 16529] New: Regression: comma separated expressions in decltype() returns incorrect type in clang++3.3
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jul 2 18:38:50 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16529
Bug ID: 16529
Summary: Regression: comma separated expressions in decltype()
returns incorrect type in clang++3.3
Product: clang
Version: 3.3
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: mlesoinne at cmsoftinc.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
In the following simple example, the return type of decltype() is incorrect
resulting in an incorrect output.
=====================Beginning of code==============================
#include <iostream>
#include <vector>
struct Yes { char x[2]; };
struct No { char x; };
template <typename T>
constexpr auto f(const T& t) -> decltype(t.end()-t.begin(), Yes{});
constexpr No f(...);
std::vector<int> v;
bool vecHasIteratorDiff = sizeof(f(v)) == sizeof(Yes);
bool intHasIteratorDiff = sizeof(f(3)) == sizeof(Yes);
int main() {
int x;
std::cout << vecHasIteratorDiff << std::endl;
std::cout << intHasIteratorDiff << std::endl;
return 0;
}
=======================End of code=================================
Output with clang++ 3.3:
0
0
Expected output (and obtained with clang++ 3.2:
1
0
It seems clang++3.3 believes the decltype() is long. Changing Yes to a basic
type gets around the problem.
--
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/20130703/e0251d6c/attachment.html>
More information about the llvm-bugs
mailing list