public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/102419] [11/12 Regression][concepts] [regression] return-type-requirement of "Y<typename T::type>" does not check that T::type actually exists
Date: Thu, 23 Sep 2021 14:58:39 +0000	[thread overview]
Message-ID: <bug-102419-4-vJlg5kwxk5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102419-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Arthur O'Dwyer from comment #4)
> > IMHO Clang/MSVC are clearly misbehaving here -- when evaluating the concept-id X<int>, they appear to be substituting {int} into X's constraint-expression instead of into the normal form of X's constraint-expression.
> 
> Isn't this situation exactly analogous to `std::void_t`?
> 
>   template<class T> using void_t = void;
>   template<class T> auto foo(T t) -> void_t<typename T::type>;  // SFINAEs
> away
>   template<class T> auto foo(T t) -> int;  // this is the only viable
> candidate
>   static_assert(std::same_as<decltype(foo(1)), int>);
> 
> The language has definitely decided that you can't preemptively fold
> `void_t<some-dependent-expression>` down to `void`;

True, that 
I don't think you should
> be allowed to preemptively fold `Y<some-dependent-expression>` down to
> `true`, either.
> I don't know for sure that Clang/MSVC have been authoritatively dubbed
> righteous, but their behavior certainly seems, to me, more consistent and
> useful than GCC's.

(In reply to Arthur O'Dwyer from comment #4)
> > IMHO Clang/MSVC are clearly misbehaving here -- when evaluating the concept-id X<int>, they appear to be substituting {int} into X's constraint-expression instead of into the normal form of X's constraint-expression.
> 
> Isn't this situation exactly analogous to `std::void_t`?
> 
>   template<class T> using void_t = void;
>   template<class T> auto foo(T t) -> void_t<typename T::type>;  // SFINAEs
> away
>   template<class T> auto foo(T t) -> int;  // this is the only viable
> candidate
>   static_assert(std::same_as<decltype(foo(1)), int>);
> 
> The language has definitely decided that you can't preemptively fold
> `void_t<some-dependent-expression>` down to `void`; I don't think you should
> be allowed to preemptively fold `Y<some-dependent-expression>` down to
> `true`, either.

I see what you mean, but I think the constraint normalization process as
currently specified forces us to effectively perform such folding. 
Specifically in the definition of an atomic constraint
([temp.constr.atomic]p1):

  An atomic constraint is formed from an expression E and a mapping from the
template parameters that appear within E to template arguments that are formed
via substitution during constraint normalization in the declaration of a
constrained entity.

the parameter mapping of an atomic constraint is defined to consist only of the
template parameters that _appear within E_.  In this case E is just 'true',
which doesn't depend on any template parameters, so the normal form of
Y<typename T::type> is just 'true (with empty parameter mapping)', which is
trivially satisfied for all T.

In order to achieve the behavior that you expect, IIUC this definition would
need to be changed to say that the parameter mapping of an atomic constraint
includes all in-scope template parameters and not only those that appear within
the expression.

  parent reply	other threads:[~2021-09-23 14:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 21:32 [Bug c++/102419] New: [concepts] " arthur.j.odwyer at gmail dot com
2021-09-21  6:46 ` [Bug c++/102419] [11/12 Regression][concepts] " rguenth at gcc dot gnu.org
2021-09-21 14:49 ` ppalka at gcc dot gnu.org
2021-09-21 14:56 ` ppalka at gcc dot gnu.org
2021-09-21 15:18 ` ppalka at gcc dot gnu.org
2021-09-21 20:00 ` arthur.j.odwyer at gmail dot com
2021-09-23 14:58 ` ppalka at gcc dot gnu.org [this message]
2022-01-17 13:29 ` rguenth at gcc dot gnu.org
2022-03-27 19:21 ` [Bug c++/102419] [11/12 Regression][concepts] " jason at gcc dot gnu.org
2022-03-27 19:22 ` jason at gcc dot gnu.org
2022-04-21  7:50 ` rguenth at gcc dot gnu.org
2023-03-30 17:08 ` [Bug c++/102419] [11/12/13 " ppalka at gcc dot gnu.org
2023-05-29 10:05 ` [Bug c++/102419] [11/12/13/14 " jakub at gcc dot gnu.org
2023-11-28 20:44 ` ppalka at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102419-4-vJlg5kwxk5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).