<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 --- - C++ parse error on complex function call template expression"
href="https://llvm.org/bugs/show_bug.cgi?id=25348">25348</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>C++ parse error on complex function call template expression
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.7
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mtanski@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I've recently tried building an application that we have using a new version of
Clang 3.7. Clang throws an error for a complex template expression for code
that g++ is able to compile. I tried to reduce this further (function instead
of FindKeyValueOp class) but that case works.
mtanski@ltsvm:~/petabucket$ cat test.cpp
#include <cstdint>
#include <vector>
enum DataType {
UINT32,
STRING,
};
template <DataType DT>
struct TypeTraits
{ };
template <>
struct TypeTraits<DataType::UINT32>
{
typedef uint32_t CppType;
};
struct Column
{
template <DataType DT>
typename TypeTraits<DT>::CppType* typed_data() {
typedef typename TypeTraits<DT>::CppType CppType;
return static_cast<CppType*>(ptr);
}
private:
DataType type;
void* ptr;
};
struct Block {
Column& column(int pos) {
return columns.at(pos);
}
private:
std::vector<Column> columns;
};
template <DataType Key, DataType Value>
struct FindKeyValueOp
{
typedef typename TypeTraits<Key>::CppType* KeyPtr;
typedef typename TypeTraits<Value>::CppType* DataPtr;
FindKeyValueOp(Block& b) : parent(b) { }
DataPtr FindKeyValue(KeyPtr key) {
KeyPtr keys = parent.column(0).typed_data<Key>();
DataPtr values = parent.column(1).typed_data<Value>();
for (unsigned i = 0; keys + i != nullptr; i++) {
if (keys[i] == *key) {
return values + i;
}
}
return nullptr;
}
private:
Block& parent;
};
int main() {
Block block;
auto op = FindKeyValueOp<DataType::UINT32,DataType::UINT32>(block);
uint32_t key = 15;
auto result = op.FindKeyValue(&key);
return 0;
}
mtanski@ltsvm:~/petabucket$ clang++-3.7 -std=c++14 test.cpp
test.cpp:50:50: error: expected expression
KeyPtr keys = parent.column(0).typed_data<Key>();
^
test.cpp:51:55: error: expected expression
DataPtr values = parent.column(1).typed_data<Value>();
^
2 errors generated.
mtanski@ltsvm:~/petabucket$ g++-4.9 -std=c++14 test.cpp
mtanski@ltsvm:~/petabucket$</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>