[Bug c++/97059] C++20: compound requirement uses inconsistent return type (adds ref)
jason at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 3 18:51:32 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97059
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu.org
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Dimitri Gorokhovik from comment #0)
> template <typename T>
> concept S = requires (T t)
> {
> { t.n } -> std::same_as <const std::size_t
> #if NOBUG
> &
> #endif
> >;
> requires std::is_same_v <decltype (t.n), const std::size_t>;
> };
>
> Compilation succeeds when NOBUG is defined, i.e., the compound requirement
> '{ t.n } ->' produces the return type as 'const std::size_t &' instead of
> 'const std::size_t'. Which is inconsistent elsewhere (see the source code
> above).
For the second 'requires' to be equivalent to the return-type-requirement, you
need another set of parentheses around "t.n".
7.5.7.3: "The immediately-declared constraint (13.2) of the type-constraint for
decltype((E)) shall be satisfied."
It's the extra parentheses that result in the reference type rather than
non-reference. GCC is correct here.
More information about the Gcc-bugs
mailing list