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

            Bug ID: 45162
           Summary: [concepts] requires expression wrongly evaluates to
                    true within a class template
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: heavenandhell...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk,
                    saar@raz.email

$ clang++.exe --version
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
fc3c80c38643aff6c4744433ab485c7550ee77b9)

$ cat test.cpp
#ifdef BUG
template <typename T>
#endif
struct test_t {
  template <typename U>
  int exec(U) {
    if constexpr (requires { this->is_memmovable<U>(); })
      return 1;
    else
      return 0;
  }

  template <typename>
    requires false
  auto is_memmovable() -> void;
};

int test() {
#ifdef BUG
  using test_type = test_t<int>;
#else
  using test_type = test_t;
#endif

  return test_type{}.exec(0);
}

$ clang++.exe -std=c++2a -O3 -c -S -o - test.cpp -DBUG
"?test@@YAHXZ":                         # @"?test@@YAHXZ"
# %bb.0:
        movl    $1, %eax
        retl

$ clang++.exe -std=c++2a -O3 -c -S -o - test.cpp
"?test@@YAHXZ":                         # @"?test@@YAHXZ"
# %bb.0:
        xorl    %eax, %eax
        retl


The requires expression only gives the wrong result if test_t is a template.
Otherwise it correctly evaluates to false.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to