Reputation: 21910
Apparently, the following code does not compile on gcc 4.7:
#include <vector>
struct foo {
std::vector<int> x;
template<typename T>
void bar(T) {
decltype(x)::value_type y;
}
};
int main() {
foo f;
f.bar(0);
}
The compilation error is the following:
test.cpp:8:9: error: need ‘typename’ before ‘decltype (((foo*)this)->foo::x)::value_type’ because ‘decltype (((foo*)this)->foo::x)’ is a dependent scope
I know the solution to the problem, but why is it not compiling? x
here is not a dependent name, so why do I need to explicitly indicate that decltype(x)::value_type
is a type if the compiler can already figure that out by himself? Or am I wrong and x
is actually a dependent name here?
Upvotes: 3
Views: 284
Reputation: 61970
Until someone finds a specific report on this (I tried looking and the closest I've found is this), this does compile with GCC 4.8.0. Based on that information and my prior suspicions, I would say this is just a bug in GCC 4.7 that was fixed for 4.8.
Upvotes: 4