public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "barry.revzin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95944] New: Concept diagnostic has multiple copies of irrelevant type and displays correct type incorrectly
Date: Sun, 28 Jun 2020 02:23:56 +0000	[thread overview]
Message-ID: <bug-95944-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 95944
           Summary: Concept diagnostic has multiple copies of irrelevant
                    type and displays correct type incorrectly
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Consider the following heavily reduced, and incorrect, attempt at an iterator:

#include <ranges>

template <typename T>
struct range {
    struct iterator {
        using reference = T;
        using value_type = T;

        auto operator*() -> T;
    };
};

static_assert(std::indirectly_readable<range<int>::iterator>);

This fails to meet the requirements of indirectly_readable because operator*()
needs to be const. This is the diagnostic I get from gcc trunk:

source>:13:20: error: static assertion failed
   13 | static_assert(std::indirectly_readable<range<int>::iterator>);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:13:20: note: constraints not satisfied
In file included from
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/stl_iterator_base_types.h:71,
                 from
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/iterator:61,
                 from
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/ranges:44,
                 from <source>:1:
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:13:
  required for the satisfaction of '__indirectly_readable_impl<typename
std::remove_cv<typename std::remove_reference<_Tp>::type>::type>' [with _Tp =
range<int>::iterator<int>]
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:42:
  in requirements with 'const _In __in' [with _Tp = range<int>::iterator<int>;
_Tp = range<int>::iterator<int>; _In = range<int>::iterator<int>]
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:451:4:
note: the required expression '* __in' is invalid
  451 |  { *__in } -> same_as<iter_reference_t<_In>>;
      |    ^~~~~
/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:452:21:
note: the required expression 'std::ranges::__cust::iter_move(__in)' is invalid
  452 |  { ranges::iter_move(__in) } -> same_as<iter_rvalue_reference_t<_In>>;
      |    ~~~~~~~~~~~~~~~~~^~~~~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more
detail
Compiler returned: 1

There are two especially important lines in this diagnostic: the one that
indicates the failed expression and the one that indicates the type of it. The
one that indicates the types is this one:

/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:42:
  in requirements with 'const _In __in' [with _Tp = range<int>::iterator<int>;
_Tp = range<int>::iterator<int>; _In = range<int>::iterator<int>]

There is only one type in the requirement (_In) but the description starts with
some type _Tp. And then we get _Tp a second time, before finally getting to
_In. _In is also displayed incorrectly: it is shown as
range<int>::iterator<int> when it should be range<int>::iterator.

Ideally this line looks closer to:

/opt/compiler-explorer/gcc-10.1.0/include/c++/10.1.0/bits/iterator_concepts.h:446:42:
  in requirements with 'const _In __in' [with _In = range<int>::iterator]

             reply	other threads:[~2020-06-28  2:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-28  2:23 barry.revzin at gmail dot com [this message]
2020-06-28  7:57 ` [Bug c++/95944] " ensadc at mailnesia dot com
2020-06-29 12:54 ` 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-95944-4@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).