[llvm-bugs] [Bug 52231] New: discarded statement and immediate invocation contexts are not mutually exclusive

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 20 04:28:10 PDT 2021


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

            Bug ID: 52231
           Summary: discarded statement and immediate invocation contexts
                    are not mutually exclusive
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2b
          Assignee: unassignedclangbugs at nondot.org
          Reporter: aaron at aaronballman.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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}}
}

```
https://godbolt.org/z/Y81nf63f7

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 https://reviews.llvm.org/D112089 for details.

-- 
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/20211020/00c84760/attachment.html>


More information about the llvm-bugs mailing list