[Bug c++/56774] New: G++ 4.8 reverses variadic template types during unpacking
w.shane.grant at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Mar 28 21:22:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56774
Bug #: 56774
Summary: G++ 4.8 reverses variadic template types during
unpacking
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: w.shane.grant@gmail.com
In g++ 4.8, it seems as if variadic templates are reversed when being unpacked.
Consider the following minimal example:
#include <tuple>
#include <iostream>
template <class T, class ... OtherT>
void something( std::tuple<T, OtherT...> & tup )
{
std::cout << std::get<1>(tup) << std::endl;
}
int main()
{
std::tuple<int, char, bool> myTuple(3, 'a', true);
// Compiles OK in GCC 4.6.3 but NOT 4.8
something<int, char, bool>( myTuple );
// Compiles OK in GCC 4.8 but NOT 4.6.3
something<int, bool, char>( myTuple );
return 0;
}
The output of this, if the appropriate line is commented out, will be: 'a'. To
get code that previously worked under 4.6.3, the template parameters that will
be unpacked have to be reversed.
See relevant Stack Overflow post here:
http://stackoverflow.com/questions/15692112/gcc-4-8-is-reversing-variadic-template-parameter-pack
More information about the Gcc-bugs
mailing list