https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94673

            Bug ID: 94673
           Summary: [concepts] What is the return type of local parameters
                    of requires expressions?
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de
  Target Milestone: ---

What should I expect when I write the following concept:

```c++
#include <utility>
#include <type_traits>

template <typename t, typename u>
concept same_as = std::is_same_v<t, u>;

template <typename t>
concept foo = requires(t v)
{
    {v} -> same_as<t>;
};

static_assert(foo<int>); // gcc 9 / clang
static_assert(foo<int &>); // clang
static_assert(foo<int const &>); // clang
```

https://godbolt.org/z/rRkCzE

* clang says that the type of the expression `v` is `t`.
* gcc 9 partially agreed on this for `foo<int>`.
* gcc 10 rejects all of them
* msvc has the same opinion as gcc10, but also fails to provide an answer why.


gcc10 gives me an (improvable?) reason why the concept failed:

```
<source>:13:15: note: constraints not satisfied
<source>:8:9:   required by the constraints of 'template<class t> concept foo'
<source>:8:15:   in requirements with 'int v'
<source>:10:6: note: 'v' does not satisfy return-type-requirement
```
  • [Bug c++/94673] New: [concepts]... gcc-bugs at marehr dot dialup.fu-berlin.de

Reply via email to