<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 - discarded statement and immediate invocation contexts are not mutually exclusive"
   href="https://bugs.llvm.org/show_bug.cgi?id=52231">52231</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>discarded statement and immediate invocation contexts are not mutually exclusive
          </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>enhancement
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>aaron@aaronballman.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
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang currently rejects this valid C++2b program:
```
consteval int *make() { return new int; }
auto f() {
  if constexpr (false) {
    if consteval {
      // Immediate function context, so call to `make()` is valid.
      // Discarded statement context, so `return 0;` is valid too.
      delete make();
      return 0;
    }
  }
  // FIXME: this error should not happen.
  return 0.0; // expected-error {{'auto' in return type deduced as 'double'
here but deduced as 'int' in earlier return statement}}
}

```
<a href="https://godbolt.org/z/Y81nf63f7">https://godbolt.org/z/Y81nf63f7</a>

This seems to happen because we treat a discarded statement evaluation context
as being mutually exclusive with an immediate invocation, but as this code
shows, they are not mutually exclusive in practice.

See <a href="https://reviews.llvm.org/D112089">https://reviews.llvm.org/D112089</a> for details.</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>