http://llvm.org/bugs/show_bug.cgi?id=20625

            Bug ID: 20625
           Summary: static constexpr member function of a local struct in
                    a function template is instantiated too late
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Example:

  template <typename T>
  void F() {
    struct Num {
      static constexpr int Get() { return 42; }
    };
    constexpr int n = Num::Get();
  }

  int main() {
    F<int>();
  }

Error message:

  a.cc:6:17: error: constexpr variable 'n' must be initialized by a constant
expression
    constexpr int n = TNum::Get();
                  ^   ~~~~~~~~~~~
  a.cc:10:3: note: in instantiation of function template specialization
'F<int>'
        requested here
    F<int>();
    ^
  a.cc:6:21: note: undefined function 'Get' cannot be used in a constant
expression
    constexpr int n = TNum::Get();
                      ^
  a.cc:4:26: note: declared here
      static constexpr int Get() { return 42; }
                           ^
  1 error generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to