[LLVMbugs] [Bug 20625] New: static constexpr member function of a local struct in a function template is instantiated too late

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 11 15:07:59 PDT 2014


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: unassignedclangbugs at nondot.org
          Reporter: mcypark at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140811/5991e22f/attachment.html>


More information about the llvm-bugs mailing list