[llvm-bugs] [Bug 45088] New: Compound requirement type constraint uses decltype(E) instead of decltype((E))
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 3 06:38:15 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=45088
Bug ID: 45088
Summary: Compound requirement type constraint uses decltype(E)
instead of decltype((E))
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++2a
Assignee: unassignedclangbugs at nondot.org
Reporter: kjcamann.lists at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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.
--
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/20200303/3180275d/attachment.html>
More information about the llvm-bugs
mailing list