<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 --- - Incorrect identification of Most Vexing Parse when expanding parameter pack and calling constructors"
href="https://llvm.org/bugs/show_bug.cgi?id=31771">31771</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect identification of Most Vexing Parse when expanding parameter pack and calling constructors
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>victory@csail.mit.edu
</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>In the C++11 program below, the indicated statement attempts to expand a
parameter pack to construct a Tuple object, used to initialize the variable
"s". Clang warns that this is a Vexing Parse and interprets the statement as a
function declaration, as well giving an error about mismatched parentheses. The
error indicates Clang realizes the statement cannot be parsed as a function
declaration. Since it isn't a function declaration, there is no ambiguity, and
Clang should reinterpret the statement as the definition and initialization of
variable "s" of type "S". I have verified that g++ has the desired behavior.
clang version 5.0.0 (trunk 293190)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ cat test.cpp
template <class ... Types>
struct Tuple {
Tuple(Types ...args) { }
} ;
template <class ... Types>
void f(Types ...args) {
struct S {
S(Tuple<Types...> t) { }
};
S s(Tuple<Types...>(args...)); // This line causes clang error!
}
int main() {
f<int,double>(1, 42.0);
return 0;
}
$ clang++ -std=c++11 -O0 -S -emit-llvm test.cpp
test.cpp:12:27: error: expected ')'
S s(Tuple<Types...>(args...)); // This line causes clang error!
^
test.cpp:12:22: note: to match this '('
S s(Tuple<Types...>(args...)); // This line causes clang error!
^
test.cpp:12:6: warning: parentheses were disambiguated as a function
declaration [-Wvexing-parse]
S s(Tuple<Types...>(args...)); // This line causes clang error!
^~~~~~~~~~~~~~~~~~~~~~~~~~
test.cpp:12:7: note: add a pair of parentheses to declare a variable
S s(Tuple<Types...>(args...)); // This line causes clang error!
^
( )
1 warning and 1 error generated.</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>