public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/97407] Expanding alias template in concept satisfaction error is undesirable
Date: Tue, 13 Oct 2020 19:10:02 +0000	[thread overview]
Message-ID: <bug-97407-4-xdUM4QFlOq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-97407-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

template<typename T> T&& declval;

template<typename R> decltype(declval<R&>().begin()) begin_impl(R&);

template<typename R>
using iter_type_impl = decltype(begin_impl(declval<R&>()));

template<typename Wat>
struct unrelated
{
  using erm = iter_type_impl<Wat>;
};

template<typename R>
using iterator_t = iter_type_impl<R>;

template<typename T> concept False = false;

template<typename R>
requires False<iterator_t<R>>
void f(R&)
{ }

int main()
{
  int a[2];
  f(a);
}


alias.C: In function ‘int main()’:
alias.C:27:6: error: use of function ‘void f(R&) [with R = int [2]]’ with
unsatisfied constraints
   27 |   f(a);
      |      ^
alias.C:21:6: note: declared here
   21 | void f(R&)
      |      ^
alias.C:21:6: note: constraints not satisfied
alias.C: In instantiation of ‘void f(R&) [with R = int [2]]’:
alias.C:27:6:   required from here
alias.C:17:30:   required for the satisfaction of ‘False<decltype
(begin_impl(declval<Wat&>()))>’ [with Wat = int[2]]
alias.C:17:38: note: the expression ‘false’ evaluated to ‘false’
   17 | template<typename T> concept False = false;
      |                                      ^~~~~


Here we print decltype (begin_impl(declval<Wat&>())) which would be better left
as iterator_t<R>, especially because "Wat" comes from a completely unrelated
class template which isn't even instantiated, but happens to use the same alias
template as iterator_t uses.

  reply	other threads:[~2020-10-13 19:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 19:04 [Bug c++/97407] New: " redi at gcc dot gnu.org
2020-10-13 19:10 ` redi at gcc dot gnu.org [this message]
2020-10-13 19:16 ` [Bug c++/97407] " redi at gcc dot gnu.org
2020-10-13 20:00 ` ppalka at gcc dot gnu.org
2021-06-10 11:45 ` redi 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-97407-4-xdUM4QFlOq@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).