<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [concepts] requires expression wrongly evaluates to true within a class template"
   href="https://bugs.llvm.org/show_bug.cgi?id=45162">45162</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[concepts] requires expression wrongly evaluates to true within a class template
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++2a
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>heavenandhell171@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, saar@raz.email
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ clang++.exe --version
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>