public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108393] New: circular concept false-positive
@ 2023-01-13 13:58 nikolasklauser at berlin dot de
  2023-01-13 16:09 ` [Bug c++/108393] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: nikolasklauser at berlin dot de @ 2023-01-13 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108393
           Summary: circular concept false-positive
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nikolasklauser at berlin dot de
  Target Milestone: ---

GCC errors on the reproducer below with

./equality_comparable.cpp: In substitution of 'template<class _Iter>  requires 
C<_Iter> constexpr bool operator==(unreachable_sentinel_t, const _Iter&) [with
_Iter = S<unreachable_sentinel_t>]':
./equality_comparable.cpp:6:41:   required by substitution of 'template<class
T>  requires requires(T __t, T __u) {__t == __u;} struct iterator_traits<T>
[with T = S<unreachable_sentinel_t>]'
./equality_comparable.cpp:11:33:   required from here
./equality_comparable.cpp:11:9:   required for the satisfaction of 'C<_Iter>'
[with _Iter = S<unreachable_sentinel_t>]
./equality_comparable.cpp:11:13:   in requirements  [with T =
S<unreachable_sentinel_t>]
./equality_comparable.cpp:11:13: error: satisfaction of atomic constraint
'requires{typename iterator_traits<T>::A;} [with T = T]' depends on itself
   11 | concept C = requires { typename iterator_traits<T>::A; };
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./equality_comparable.cpp: In substitution of 'template<class _Iter>  requires 
C<_Iter> constexpr bool operator==(unreachable_sentinel_t, const _Iter&) [with
_Iter = S<unreachable_sentinel_t>]':
./equality_comparable.cpp:6:41:   required by substitution of 'template<class
T>  requires requires(T __t, T __u) {__t == __u;} struct iterator_traits<T>
[with T = S<unreachable_sentinel_t>]'
./equality_comparable.cpp:11:33:   required from here
./equality_comparable.cpp:11:9:   required for the satisfaction of 'C<_Iter>'
[with _Iter = S<unreachable_sentinel_t>]
./equality_comparable.cpp:11:13:   in requirements  [with T =
S<unreachable_sentinel_t>]
./equality_comparable.cpp:11:13: error: satisfaction of atomic constraint
'requires{typename iterator_traits<T>::A;} [with T = T]' depends on itself

But AFAICT this code should compile just fine.
iterator_traits<unreachable_sentinel_t> should never get instantiated and I
don't see another way this would result in a self-reference.

reproducer (Godbolt: https://godbolt.org/z/cfP5fqcMc):

template<class>
struct iterator_traits
{};

template<class T>
  requires requires(T __t, T __u) { __t == __u; }
struct iterator_traits<T>
{};

template<class T>
concept C = requires { typename iterator_traits<T>::A; };

struct unreachable_sentinel_t
{
  template<C _Iter>
  friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&)
noexcept;
};

template<class T>
struct S
{};

static_assert(!C<S<unreachable_sentinel_t>>);

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

end of thread, other threads:[~2024-03-09 15:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 13:58 [Bug c++/108393] New: circular concept false-positive nikolasklauser at berlin dot de
2023-01-13 16:09 ` [Bug c++/108393] " redi at gcc dot gnu.org
2023-01-13 16:15 ` redi at gcc dot gnu.org
2023-01-13 16:28 ` ppalka at gcc dot gnu.org
2023-01-27 17:02 ` pinskia at gcc dot gnu.org
2023-05-19  3:34 ` pinskia at gcc dot gnu.org
2024-03-09 15:37 ` ppalka 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).