public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112490] New: infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>>
@ 2023-11-12 11:33 hewillk at gmail dot com
2023-11-13 0:20 ` [Bug c++/112490] " pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: hewillk at gmail dot com @ 2023-11-12 11:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112490
Bug ID: 112490
Summary: infinite meta error in
reverse_iterator<basic_const_iterator<vector<int>::ite
rator>>
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
#include <iterator>
#include <vector>
using I = std::vector<int>::iterator;
using CI = std::basic_const_iterator<I>;
using RCI = std::reverse_iterator<CI>;
static_assert(std::totally_ordered<RCI>);
https://godbolt.org/z/14zsETc4d
The fact that libc++ does not generate an error suggests that this may be a
language bug.
Not sure where the real issue here, I will reduce it when I have time.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/112490] infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>>
2023-11-12 11:33 [Bug c++/112490] New: infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>> hewillk at gmail dot com
@ 2023-11-13 0:20 ` pinskia at gcc dot gnu.org
2023-11-13 0:21 ` pinskia at gcc dot gnu.org
2024-04-05 17:45 ` barry.revzin at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-13 0:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112490
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well clang does not implement CWG2369 resolution.
Which GCC implemented in r11-2774 . So it might be that is the reason why GCC
rejects it and clang does not.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/112490] infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>>
2023-11-12 11:33 [Bug c++/112490] New: infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>> hewillk at gmail dot com
2023-11-13 0:20 ` [Bug c++/112490] " pinskia at gcc dot gnu.org
@ 2023-11-13 0:21 ` pinskia at gcc dot gnu.org
2024-04-05 17:45 ` barry.revzin at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-13 0:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112490
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=99599
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Also see PR 99599 .
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/112490] infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>>
2023-11-12 11:33 [Bug c++/112490] New: infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>> hewillk at gmail dot com
2023-11-13 0:20 ` [Bug c++/112490] " pinskia at gcc dot gnu.org
2023-11-13 0:21 ` pinskia at gcc dot gnu.org
@ 2024-04-05 17:45 ` barry.revzin at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: barry.revzin at gmail dot com @ 2024-04-05 17:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112490
Barry Revzin <barry.revzin at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |barry.revzin at gmail dot com
--- Comment #3 from Barry Revzin <barry.revzin at gmail dot com> ---
I ran into this also in a different direction, have been trying to reduce:
#include <compare>
template <class T, class U> concept my_partially_ordered_with = requires (T t,
U u) { t < u; };
template <class T> concept my_totally_ordered = my_partially_ordered_with<T,
T>;
template <class T, class U> concept my_totally_ordered_with =
my_totally_ordered<T> && my_totally_ordered<U> && my_partially_ordered_with<T,
U>;
template<class _It> class basic_const_iterator;
namespace __detail
{
template<typename _Tp>
inline constexpr bool __is_const_iterator = false;
template<typename _It>
inline constexpr bool __is_const_iterator<basic_const_iterator<_It>> =
true;
template<typename _Tp>
concept __not_a_const_iterator = !__is_const_iterator<_Tp>;
} // namespace detail
template<class _It>
class basic_const_iterator
{
#ifdef MAKE_THIS_PUBLIC
public:
#endif
int m;
public:
template <__detail::__not_a_const_iterator _It2>
friend bool operator<(const _It2& __x, const basic_const_iterator& __y)
requires my_totally_ordered_with<_It, _It2> { return true; }
};
template <class Iter>
struct wrapped
{
Iter iter;
constexpr std::strong_ordering operator<=>(const wrapped& rhs) const
noexcept;
};
bool check(wrapped<basic_const_iterator<int*>> x) {
return x < x;
}
gcc rejects this with constraint recursion. clang and MSVC accept. Oddly, if
you make _M_current public, gcc trunk accepts (even though no code even
references this) while gcc 13.2 still rejects. On compiler explorer:
https://godbolt.org/z/zfvxdGneK
Trunk's rejection message is also incomplete:
<source>: In substitution of 'template<class _It2> requires
__not_a_const_iterator<_It2> bool operator<(const _It2&, const
basic_const_iterator<int*>&) requires my_totally_ordered_with<_It, _It2> [with
_It2 = int*]':
<source>:3:89: required by substitution of 'template<class _It2> requires
__not_a_const_iterator<_It2> bool operator<(const _It2&, const
basic_const_iterator<int*>&) requires my_totally_ordered_with<_It, _It2> [with
_It2 = int*]'
3 | template <class T, class U> concept my_partially_ordered_with =
requires (T t, U u) { t < u; };
|
~~^~~
<source>:43:16: required from here
43 | return x < x;
| ^
It tells you _It2=int*, but not what _It is.
In this case, we're comparing two objects of type
wrapped<basic_const_iterator<int*>> with <, so we should have two candidates:
1. wrapped's <=>, which has no constraints
2. basic_const_iterator<int*>'s friend operator<, which we start instantiating
with _It=int* and _It2=wrapped<basic_const_iterator<int*>>.
(2) requires checking if _It and _It2 can be ordered, which I think recursively
instantiates itself.
Assuming that's correct (hopefully?), I think CWG 2369 should actually cause
this to be accepted - since wrapped<basic_const_iterator<int*>> is not
convertible to basic_const_iterator<int*>, that should cause (2) to be rejected
before we even consider constraints since it's not viable.
I have no idea what the public-ness of the member changes.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-05 17:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 11:33 [Bug c++/112490] New: infinite meta error in reverse_iterator<basic_const_iterator<vector<int>::iterator>> hewillk at gmail dot com
2023-11-13 0:20 ` [Bug c++/112490] " pinskia at gcc dot gnu.org
2023-11-13 0:21 ` pinskia at gcc dot gnu.org
2024-04-05 17:45 ` barry.revzin at gmail dot com
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).