http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49224

           Summary: Scoped enumeration instantiated even if not required
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: schaub.johan...@googlemail.com


GCC should not instantiate the definition of the scoped enumeration:

template<typename T>
struct A {
  enum class B {
    X = T::value
  };
};

int main() {
  A<int> a;
}

GCC error:

main1.cpp: In instantiation of ‘A<int>’:
main1.cpp:9:10:   instantiated from here
main1.cpp:3:14: error: ‘value’ is not a member of ‘int’

This code looks well-formed. Only if we look into the enumeration, as
"A<int>::B::X", the definition of the enumeration is required to exist and thus
implicitly instantiated. This is specified at 14.7.1p1 and p2.

Reply via email to