[Bug c++/94673] [concepts] What is the return type of local parameters of requires expressions?

ppalka at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Sep 21 17:48:45 GMT 2021


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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to gcc-bugs from comment #3)
> I think this bug should be changed to a request to improve the diagnostics.
> 
> The diagnostic says:
> 
> ```
> <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 't v' [with t = int]
> <source>:10:6: note: 'v' does not satisfy return-type-requirement
>    10 |     {v} -> same_as<t>;
>       |      ^
> ```
> 
> If you don't know that `{v}` should be read as `{(v)}`, it is confusing that
> the diagnostic says that `'t v' [with t = int]` does not satisfy that the
> type of the expression `{ v }` is `t`.
> 
> I think the diagnostic for the return-type-requirement should add the reason
> / diagnostic why it isn't fulfilled, so basically the same reason that
> `static_assert(std::same_as<decltype((v)), int>);` would give.
> 
> > note: the expression 'is_same_v<_Tp, _Up> [with _Tp = int&; _Up = int]' evaluated to 'false'
> >   57 |       concept __same_as = std::is_same_v<_Tp, _Up>;
> >      |                           ~~~~~^~~~~~~~~~~~~~~~~~~

Don't we already do this with -fconcepts-diagnostics-depth=2 ?


More information about the Gcc-bugs mailing list