방금 GCC 4.8로 업그레이드했고 일부 가변적 인 템플릿 코드가 더 이상 올바르게 컴파일되지 않습니다.GCC 4.8이 variadic 템플릿 매개 변수 팩을 뒤집습니다.
#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;
}
이의 출력이 될 것입니다 'A'(GCC 4.6.3/4.8에 대한 잘못된 버전을 주석 경우) : 나는 아래 최소한의 예를 만들었습니다.
GCC 4.6.3에 의해 생성 된 오류 :
./test.cpp: In function ‘int main()’:
./test.cpp:18:39: error: no matching function for call to ‘something(std::tuple<int, char, bool>&)’
./test.cpp:18:39: note: candidate is:
./test.cpp:5:6: note: template<class T, class ... OtherT> void something(std::tuple<_Head, _Tail ...>&)
GCC 4.8에 의해 생성 된 오류 : 팽창시 GCC 4.8에서 가변 템플릿 유형이 반전처럼
./test.cpp: In function ‘int main()’:
./test.cpp:15:39: error: no matching function for call to ‘something(std::tuple<int, char, bool>&)’
something<int, char, bool>(myTuple);
^
./test.cpp:15:39: note: candidate is:
./test.cpp:5:6: note: template<class T, class ... OtherT> void something(std::tuple<_El0, _El ...>&)
void something(std::tuple<T, OtherT...> & tup)
^
./test.cpp:5:6: note: template argument deduction/substitution failed:
./test.cpp:15:39: note: mismatched types ‘bool’ and ‘char’
something<int, char, bool>(myTuple);
것 같다 이상하게도 그들은 출력에 의해 증명 된 것처럼 "정말로"되돌아 가지는 않는다. 주문과 상관없이 'a'가 될 것이다. Clang 3.3은 GCC 4.6.3 출력에 동의합니다.
GCC 4.8 또는 다른 버그입니까?
편집 : 여기 GCC에 버그 리포트를 추가 : http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56774이 나에게 벌레처럼 보이는