<html>
<head>
<base href="http://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 --- - Regression: comma separated expressions in decltype() returns incorrect type in clang++3.3"
href="http://llvm.org/bugs/show_bug.cgi?id=16529">16529</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Regression: comma separated expressions in decltype() returns incorrect type in clang++3.3
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.3
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>C++11
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mlesoinne@cmsoftinc.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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.</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>