https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68309
Bug ID: 68309
Summary: [C++14] Expanding a captured parameter pack with
std::forward<decltype(args)>(args) fails.
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ralph.tandetzky at gmail dot com
Target Milestone: ---
Here's a minimal not-working example:
#include <iostream>
using namespace std;
template <typename ...Ts>
void print( Ts &&... args )
{
[&]
{
const auto _ = {
((cout << forward<decltype(args)>(args) << endl),0)... };
(void)_;
}();
}
int main()
{
print( 1, "blub", std::to_string(3.1415), 4, 5.2 );
}
This code fails with GCC 4.9. GCC 5.2 even crashes with a segfault. Clang 3.6
compiles it and gives the expected console output:
1
blub
3.141500
4
5.2
The curious thing is: When I remove the wrapping lambda, i.e. the line
[&]
{
}();
then is compiles fine in all cases. Also when I replace decltype(args) with Ts,
then it compiles fine and produces the correct console output. Go figure!