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

            Bug ID: 120056
           Summary: Circular constraint satisfaction error with
                    non-trivial container iterators to callables taking
                    std::expected parameters
           Product: gcc
           Version: 15.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: catsith at me dot com
  Target Milestone: ---

Created attachment 61265
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61265&action=edit
example .ii

$ g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.1 20250425 (GCC)

$ cat > gcc.cpp
#include <expected>
#include <vector>

int main() {
  // std::expected template arguments don't matter
  using func = void (*)(std::expected<int, bool>);
  // fails with std::deque, std::list, std::vector; works with std::array
  std::vector<func> v;
  return v.begin() == v.end();
}

$ g++ -std=c++23 -save-temps gcc.cpp
In file included from gcc.cpp:1:
/usr/include/c++/15.1.1/expected: In substitution of ‘template<class _Up> 
requires !(__is_expected<_Up>) && requires(const _Tp& __t, const _Up& __u)
{{__t == __u} -> decltype(auto) [requires std::convertible_to<<placeholder>,
bool>];} constexpr bool std::operator==(const expected<int, bool>&, const _Up&)
[with _Up = __gnu_cxx::__normal_iterator<void (**)(std::expected<int, bool>),
std::vector<void (*)(std::expected<int, bool>)> >]’:
/usr/include/c++/15.1.1/expected:1175:12:   required by substitution of
‘template<class _Up>  requires !(__is_expected<_Up>) && requires(const _Tp&
__t, const _Up& __u) {{__t == __u} -> decltype(auto) [requires
std::convertible_to<<placeholder>, bool>];} constexpr bool
std::operator==(const expected<int, bool>&, const _Up&) [with _Up =
__gnu_cxx::__normal_iterator<void (**)(std::expected<int, bool>),
std::vector<void (*)(std::expected<int, bool>)> >]’
 1175 |             { __t == __u } -> convertible_to<bool>;
      |               ~~~~^~~~~~
gcc.cpp:9:29:   required from here
    9 |   return v.begin() == v.end();
      |                             ^
/usr/include/c++/15.1.1/expected:1178:2:   required by the constraints of
‘template<class _Tp, class _Er> template<class _Up>  requires
!(__is_expected<_Up>) && requires(const _Tp& __t, const _Up& __u) {{__t == __u}
-> decltype(auto) [requires std::convertible_to<<placeholder>, bool>];}
constexpr bool std::operator==(const expected<_Tp, _Er>&, const _Up&)’
/usr/include/c++/15.1.1/expected:1174:7:   in requirements with ‘const _Tp&
__t’, ‘const _Up& __u’ [with _Tp = int; _Up = __gnu_cxx::__normal_iterator<void
(**)(std::expected<int, bool>), std::vector<void (*)(std::expected<int, bool>),
std::allocator<void (*)(std::expected<int, bool>)> > >]
/usr/include/c++/15.1.1/expected:1174:14: error: satisfaction of atomic
constraint ‘requires(const _Tp& __t, const _Up& __u) {{__t == __u} ->
decltype(auto) [requires std::convertible_to<<placeholder>, bool>];} [with _Tp
= _Tp; _Up = _Up]’ depends on itself
 1174 |           && requires (const _Tp& __t, const _Up& __u) {
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1175 |             { __t == __u } -> convertible_to<bool>;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1176 |           }
      |           ~

Reply via email to