<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 - Compound requirement type constraint uses decltype(E) instead of decltype((E))"
   href="https://bugs.llvm.org/show_bug.cgi?id=45088">45088</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compound requirement type constraint uses decltype(E) instead of decltype((E))
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>kjcamann.lists@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
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following program should compile in clang but does not. It does work in gcc
10:

```
#include <type_traits>

template <typename T>
concept reference = std::is_reference_v<T>;

struct S {
  int i;
};

template <typename T>
concept C = requires(T &t) {
  { t.i } -> reference;
};

static_assert( C<S> ); // static_assert fails
```

The issue here is that according to [expr.prim.req.compound]p1.3.2, the type
substituted into the type constraint should be decltype((E)), with the extra
parentheses to inhibit the corner case rule for decltype
([dcl.type.decltype]p1.3) that makes id expressions and class member access
expressions into just T rather than the normal T& for lvalue category
expressions. clang uses `decltype(E)` rather than `decltype((E))` and even says
so in the diagnostic:

"note: because 'decltype(t.i)' (aka 'int')  does not satisfy 'reference'"

This bug is present in both clang 10 and in trunk.</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>