public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ensadc at mailnesia dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95310] [concepts] Unrelated template parameters printed in diagnostic
Date: Sat, 17 Oct 2020 05:31:20 +0000	[thread overview]
Message-ID: <bug-95310-4-ENWv1OZ5lS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95310-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from ensadc at mailnesia dot com ---
When verifying the fix, I noticed a new bug:

====
template <class T> requires true
using iter_reference_t = decltype(*T{});

template <typename F>
struct result {
  using type = iter_reference_t<F>;
};

template <class Out, class T>
concept indirectly_writable = requires(Out&& o, T&& t) {
  iter_reference_t<Out>(*o) = 0;
};

template<class In, class Out>
requires indirectly_writable<Out, iter_reference_t<In>>
void copy(In in, Out out) {}

void test(const int* p, int* q) {
    copy(q, p);
}

====
<source>: In function 'void test(const int*, int*)':
<source>:19:14: error: no matching function for call to 'copy(int*&, const
int*&)'
   19 |     copy(q, p);
      |              ^
<source>:16:6: note: candidate: 'template<class In, class Out>  requires 
indirectly_writable<Out, decltype(*{})> void copy(In, Out)'
   16 | void copy(In in, Out out) {}
      |      ^~~~
<source>:16:6: note:   template argument deduction/substitution failed:
<source>:16:6: note: constraints not satisfied
<source>: In substitution of 'template<class In, class Out>  requires 
indirectly_writable<Out, decltype(*{})> void copy(In, Out) [with In = int*; Out
= const int*]':
<source>:19:14:   required from here
<source>:10:9:   required for the satisfaction of 'indirectly_writable<Out,
iter_reference_t<F> >' [with Out = const int*; In = int*]
<source>:10:31:   in requirements with 'Out&& o', 'T&& t' [with T = int&; Out =
const int*]
<source>:11:29: note: the required expression 'decltype(*{})(*o)=0' is invalid
   11 |   iter_reference_t<Out>(*o) = 0;
      |   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more
detail
====

In

  <source>:10:9:   required for the satisfaction of 'indirectly_writable<Out,
iter_reference_t<F> >' [with Out = const int*; In = int*]

Note the mismatch between `F` and `In`.

GCC 10.2 prints `F = int*` instead of `In = int*`:

  <source>:10:9:   required for the satisfaction of 'indirectly_writable<Out,
iter_reference_t<F> >' [with Out = const int*; F = int*]

The name `F` comes from a completely unrelated class template, but at least the
names match in GCC 10.2.

(Interestingly, the alias template is not expanded in this line.)

  parent reply	other threads:[~2020-10-17  5:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  8:46 [Bug c++/95310] New: " ensadc at mailnesia dot com
2020-05-27 14:12 ` [Bug c++/95310] " ppalka at gcc dot gnu.org
2020-10-13 19:39 ` redi at gcc dot gnu.org
2020-10-17  5:31 ` ensadc at mailnesia dot com [this message]
2020-10-20  3:20 ` 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-95310-4-ENWv1OZ5lS@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).