Enum local to a function in C++03

56 views Asked by At

Why is the following snippet not legal in C++03?

template <typename T>
void poison(T& x) {}

int main() {
    enum Enum { A, B, C };
    Enum e = A;
    poison(e);
    return 0;
}

gcc 5.4 compiler output in C++03 mode: https://godbolt.org/g/6hKc7F

If I move Enum outside main(), it compiles fine in C++03 mode. Alternatively, if I enable C++11, it compiles fine as well.

How did scoping rules change between C++03 and C++11 such that this code is now valid?

0

There are 0 answers