[llvm-bugs] [Bug 50276] New: [concepts] error: out-of-line definition of 'length' from class 'utf_t<type-parameter-0-0>' without definition

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 8 13:31:31 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50276

            Bug ID: 50276
           Summary: [concepts] error: out-of-line definition of 'length'
                    from class 'utf_t<type-parameter-0-0>' without
                    definition
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: heavenandhell171 at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

$ cat utf.cpp
#include <concepts>

template <typename>
struct utf_t;

template <typename T>
    requires (std::is_same_v<T, char32_t>) ||
             (std::is_same_v<T, wchar_t> && sizeof(wchar_t) ==
sizeof(char32_t))
struct utf_t<T> {
  utf_t() {
  }

  template <typename Input>
  static auto length(Input begin, Input const end) -> unsigned;
};

template <typename T>
    requires (std::is_same_v<T, char32_t>) ||
             (std::is_same_v<T, wchar_t> && sizeof(wchar_t) ==
sizeof(char32_t))
template <typename Input>
inline auto utf_t<T>::length(Input begin, Input const end) -> unsigned {
  return 0;
}

$ clang++ -std=c++20 utf.cpp
utf.cpp:21:23: error: out-of-line definition of 'length' from class
'utf_t<type-parameter-0-0>' without definition
inline auto utf_t<T>::length(Input begin, Input const end) -> unsigned {
            ~~~~~~~~~~^
1 error generated.

No matter how you constrain it, it doesn't work:
https://godbolt.org/z/qqaM89nTx

GCC compiles it without any error: https://godbolt.org/z/PM3seoYvW

-- 
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/20210508/21c4789c/attachment.html>


More information about the llvm-bugs mailing list