public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang
@ 2021-10-18  6:54 zeratul976 at hotmail dot com
  2021-10-18  7:15 ` [Bug libstdc++/102807] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zeratul976 at hotmail dot com @ 2021-10-18  6:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102807
           Summary: Simple code using ranges::views::keys does not compile
                    with clang
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeratul976 at hotmail dot com
  Target Milestone: ---

Created attachment 51620
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51620&action=edit
Output of `clang++ -c -std=c++20 -ftemplate-backtrace-limit=0 `

The following simple code using ranges::views::keys compiles with gcc 11.1, but
not with clang (tested with clang trunk, and libstdc++ from 11.1).


#include <ranges>
#include <unordered_map>

int main()
{
    std::unordered_map<int, int> m;
    m | std::ranges::views::keys;
}


I've attached the complete error output. I'm not sure if this is a bug in clang
or libstdc++, but I thought I'd start here.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
@ 2021-10-18  7:15 ` pinskia at gcc dot gnu.org
  2021-10-18  9:02 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-18  7:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This could be a bug in clang considering it uses concepts and all.
clang does not say why this concept evulates to false even:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/iterator_concepts.h:964:16:
note: because 'is_array_v<std::ranges::ref_view<std::unordered_map<int, int> >
>' evaluated to false

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
  2021-10-18  7:15 ` [Bug libstdc++/102807] " pinskia at gcc dot gnu.org
@ 2021-10-18  9:02 ` redi at gcc dot gnu.org
  2021-10-18  9:10 ` pilarlatiesa at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-18  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It evaluates to false because is_array_v<T> is false for that type.

The next candidate is the problem:

and 'std::ranges::ref_view<std::unordered_map<int, int>> &' does not satisfy
'__member_begin'
because '__decay_copy(__t.begin())' would be invalid: no member named 'begin'
in 'std::ranges::ref_view<std::unordered_map<int, int>>'

That's wrong. I don't know why ref_view::begin() isn't usable.

Reduced:

#include <ranges>

struct Range
{
  int* begin() { return &i; }
  int* end() { return begin() + 1; }
  const int* begin() const { return &i; }
  const int* end() const { return begin() + 1; }

  int i = 0;
};

int main()
{
    static_assert(std::ranges::range<Range>);
    static_assert(std::ranges::range<const Range>);
    using R = std::ranges::ref_view<Range>;
    static_assert(std::ranges::range<R>);
    using I = decltype(std::declval<R&>().begin());
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
  2021-10-18  7:15 ` [Bug libstdc++/102807] " pinskia at gcc dot gnu.org
  2021-10-18  9:02 ` redi at gcc dot gnu.org
@ 2021-10-18  9:10 ` pilarlatiesa at gmail dot com
  2021-10-18  9:12 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pilarlatiesa at gmail dot com @ 2021-10-18  9:10 UTC (permalink / raw)
  To: gcc-bugs

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

Pilar Latiesa <pilarlatiesa at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pilarlatiesa at gmail dot com

--- Comment #3 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
I believe this is a consequence of Clang bug 44833.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
                   ` (2 preceding siblings ...)
  2021-10-18  9:10 ` pilarlatiesa at gmail dot com
@ 2021-10-18  9:12 ` redi at gcc dot gnu.org
  2021-10-18  9:14 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-18  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
#include <ranges>

struct Range
{
  int* begin() { return 0; }
  int* end() { return 0; }
};

int main()
{
    static_assert(std::ranges::range<Range>);
    using R = std::ranges::ref_view<Range>;
    static_assert( std::ranges::__cust_access::__member_begin<R> );
}

The problem happens when instantiating ref_view<R> for any R. The
view_interface<ref_view<R>> CRTP base class gets instantiated and that checks
the constraints of its member functions, which depends on the derived class,
which is incomplete at that point.

I think this is a clang bug. It should not be checking the constraints for
view_interface<ref_view<Range>>::data() when checking satisfaction of
range<ref_view<Range>>.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
                   ` (3 preceding siblings ...)
  2021-10-18  9:12 ` redi at gcc dot gnu.org
@ 2021-10-18  9:14 ` redi at gcc dot gnu.org
  2022-01-11 21:18 ` redi at gcc dot gnu.org
  2022-03-18 15:40 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-18  9:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |MOVED
             Status|UNCONFIRMED                 |RESOLVED
           See Also|                            |https://bugs.llvm.org/show_
                   |                            |bug.cgi?id=44833

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Pilar Latiesa from comment #3)
> I believe this is a consequence of Clang bug 44833.

Ah yes, that's exactly it. Thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
                   ` (4 preceding siblings ...)
  2021-10-18  9:14 ` redi at gcc dot gnu.org
@ 2022-01-11 21:18 ` redi at gcc dot gnu.org
  2022-03-18 15:40 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-01-11 21:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unlvsur at live dot com

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 103982 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug libstdc++/102807] Simple code using ranges::views::keys does not compile with clang
  2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
                   ` (5 preceding siblings ...)
  2022-01-11 21:18 ` redi at gcc dot gnu.org
@ 2022-03-18 15:40 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-18 15:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://reviews.llvm.org/D119544 should fix this when it lands.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-18 15:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18  6:54 [Bug libstdc++/102807] New: Simple code using ranges::views::keys does not compile with clang zeratul976 at hotmail dot com
2021-10-18  7:15 ` [Bug libstdc++/102807] " pinskia at gcc dot gnu.org
2021-10-18  9:02 ` redi at gcc dot gnu.org
2021-10-18  9:10 ` pilarlatiesa at gmail dot com
2021-10-18  9:12 ` redi at gcc dot gnu.org
2021-10-18  9:14 ` redi at gcc dot gnu.org
2022-01-11 21:18 ` redi at gcc dot gnu.org
2022-03-18 15:40 ` redi at gcc dot gnu.org

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).