Utilisation de funcName () avant la déduction de auto – pourquoi dans un cas mais pas dans l’autre?

Considérons le code suivant:

#include  #include  namespace Test { template struct StateTableEntry { State state; }; template using StateRow = std::unordered_map<int,StateTableEntry>; template auto& entryBAD(StateRowValueType& row) { return row.second; } template auto entryOK(StateRowValueType& row) -> decltype((row.second)) { return row.second; } } template std::enable_if_t<I==std::tuple_size::value> for_each_index_of(O&){} template std::enable_if_t<startingIndex<std::tuple_size::value> for_each_index_of(const Operation& operation) { operation(std::integral_constant()); for_each_index_of(operation); } int main() { for_each_index_of<std::tuple>([](const auto&) { Test::StateRow stateRow; for(auto& rowElement : stateRow) { auto& state(entryBAD(rowElement).state); state=1; } }); } 

Si j’essaie de le comstackr tel quel, gcc me dit

 test.cpp: In instantiation of 'main():: [with auto:1 = std::integral_constant]': test.cpp:29:14: required from 'std::enable_if_t<(startingIndex < std::tuple_size::value)> for_each_index_of(const Operation&) [with Tuple = std::tuple; int startingIndex = 0; Operation = main()::; std::enable_if_t<(startingIndex < std::tuple_size::value)> = void]' test.cpp:43:6: required from here test.cpp:40:44: error: use of 'template auto& Test::entryBAD(StateRowValueType&)' before deduction of 'auto' auto& state(entryBAD(rowElement).state); ^ test.cpp:40:44: error: use of 'auto& Test::entryBAD(StateRowValueType&) [with StateRowValueType = std::pair<const int, Test::StateTableEntry >]' before deduction of 'auto' test.cpp:24:1: error: 'std::enable_if_t<(I == std::tuple_size::value)> for_each_index_of(O&) [with T = std::tuple; int I = 1; O = const main()::; std::enable_if_t<(I == std::tuple_size::value)> = void]', declared using local type 'const main()::', is used but never defined [-fpermissive] for_each_index_of(O&){} ^ 

Mais si je déplace le conde de lambda hors du lambda ou remplace l’appel de entryBAD par entryOK , pour une raison quelconque, la compilation réussit. Même succès si je déplace la définition de entryBAD hors de l’ namespace Test de namespace Test .

Clang ++ 3.6 est également compilé dans tous les cas sans réclamation.

Gcc a-t-il raison ou s’agit-il d’un bug? Si gcc a raison, quel est le problème avec le code?