<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 - Consteval functions in unevaluted context"
   href="https://bugs.llvm.org/show_bug.cgi?id=47350">47350</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Consteval functions in unevaluted context
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>11.0
          </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>enhancement
          </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>dudkindaniilm2@yandex.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23903" name="attach_23903" title="The code">attachment 23903</a> <a href="attachment.cgi?id=23903&action=edit" title="The code">[details]</a></span>
The code

The problem is reproducible with clang 11 and clang trunk

Code:

struct N {
  constexpr N() {}
  N(N const&) = delete;
};
template <typename T> constexpr void bad_assert_copyable() { T t; T t2 = t; }
using ineffective = decltype(bad_assert_copyable<N>());

template <typename T> consteval void assert_copyable() { T t; T t2 = t; }
using check = decltype(assert_copyable<N>());

int main() {}

Link 1. <a href="https://godbolt.org/z/j9TTed">https://godbolt.org/z/j9TTed</a>
Link 2. <a href="https://wandbox.org/permlink/jYwoQg7pKd4mMMwv">https://wandbox.org/permlink/jYwoQg7pKd4mMMwv</a>

Before P1937R2 were merged into C++20 draft it really was an illegal code
because in unevaluted context consteval function must be evaluted. But now it's
totally legal code.

Link 3. P1937R2:
<a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1937r2.html">http://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1937r2.html</a>

Local compile using clang build from LLVM 11.0.0-rc2:

$ ./clang++ -v
clang version 11.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
0160ad802e899c2922bc9b29564080c22eb0908c)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /mnt/c/clang+llvm-11.0.0-rc2-x86_64-linux-gnu-ubuntu-20.04/bin/.
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

$ ./clang++ test/bug.cpp -std=c++2a
test/bug.cpp:10:24: error: call to consteval function 'assert_copyable<N>' is
not a constant expression
using check = decltype(assert_copyable<N>());
                       ^
test/bug.cpp:10:24: note: undefined function 'assert_copyable<N>' cannot be
used in a constant expression
test/bug.cpp:9:37: note: declared here
template<typename T> consteval void assert_copyable() { T t; T t2 = t; }
                                    ^
1 error generated.</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>