Skip to content

g++-15 with CXX_MODULES does not compile friends #15

@ClausKlein

Description

@ClausKlein

i.e.:

[[nodiscard]] friend inline constexpr decltype(auto) operator|(Box&& box, A&& a) noexcept
[10/96] Building CXX object tests/beman/monadics/CMakeFiles/beman.monadics.tests.optional.or_else.dir/optional/or_else.test.cpp.o
FAILED: [code=1] tests/beman/monadics/CMakeFiles/beman.monadics.tests.optional.or_else.dir/optional/or_else.test.cpp.o 
ccache /usr/local/Cellar/llvm/22.1.1/bin/clang++  -I/Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/or_else -I/Users/clausklein/Workspace/cpp/beman-project/monadics/include -isystem /usr/local/include -O3 -DNDEBUG -std=c++23 -MD -MT tests/beman/monadics/CMakeFiles/beman.monadics.tests.optional.or_else.dir/optional/or_else.test.cpp.o -MF tests/beman/monadics/CMakeFiles/beman.monadics.tests.optional.or_else.dir/optional/or_else.test.cpp.o.d -o tests/beman/monadics/CMakeFiles/beman.monadics.tests.optional.or_else.dir/optional/or_else.test.cpp.o -c /Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/optional/or_else.test.cpp
/Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/optional/or_else.test.cpp:12:47: error: invalid operands to binary expression ('std::optional<int>' (aka 'optional<int>') and 'action<decltype(fn)>' (aka 'action<(lambda at /Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/optional/or_else.test.cpp:12:57) &&>'))
   12 |     constexpr auto result = std::optional{10} | or_else([]() { return std::optional{100}; });
      |                             ~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/22.1.1/bin/../include/c++/v1/__cstddef/byte.h:26:45: note: candidate function not viable: no known conversion from 'std::optional<int>' (aka 'optional<int>') to 'byte' for 1st argument
   26 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
      |                                             ^         ~~~~~~~~~~
/usr/local/Cellar/llvm/22.1.1/bin/../include/c++/v1/__charconv/chars_format.h:34:53: note: candidate function not viable: no known conversion from 'std::optional<int>' (aka 'optional<int>') to 'chars_format' for 1st argument
   34 | inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator|(chars_format __x, chars_format __y) {
      |                                                     ^         ~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/22.1.1/bin/../include/c++/v1/bitset:941:1: note: candidate template ignored: could not match 'bitset' against 'optional'
  941 | operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
      | ^
/Users/clausklein/Workspace/cpp/beman-project/monadics/include/beman/monadics/detail/or_else.hpp:23:62: note: candidate template ignored: substitution failure [with Box = std::optional<int>, A = action<decltype(fn)>]: constraints not satisfied for alias template 'get_box_traits' [with T = std::optional<int>]
   22 |         template <is_box Box, same_unqualified_as<action> A, typename Traits = get_box_traits<Box> >
      |                                                                                ~~~~~~~~~~~~~~
   23 |         [[nodiscard]] friend inline constexpr decltype(auto) operator|(Box&& box, A&& a) noexcept
      |                                                              ^
/Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/optional/or_else.test.cpp:13:5: error: expected expression
   13 |     STATIC_REQUIRE(std::same_as<decltype(result), const std::optional<int>>);
      |     ^
/usr/local/include/catch2/catch_test_macros.hpp:171:69: note: expanded from macro 'STATIC_REQUIRE'
  171 |     #define STATIC_REQUIRE( ... )       static_assert(   __VA_ARGS__,  #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ )
      |                                                                     ^
/Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/optional/or_else.test.cpp:20:50: error: invalid operands to binary expression ('std::optional<int>' and 'action<decltype(fn)>' (aka 'action<(lambda at /Users/clausklein/Workspace/cpp/beman-project/monadics/tests/beman/monadics/optional/or_else.test.cpp:20:60) &&>'))
   20 |     constexpr auto result = std::optional<int>{} | or_else([]() { return std::optional{'c'}; });
      |                             ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/22.1.1/bin/../include/c++/v1/__cstddef/byte.h:26:45: note: candidate function not viable: no known conversion from 'std::optional<int>' to 'byte' for 1st argument
   26 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
      |                                             ^         ~~~~~~~~~~
/usr/local/Cellar/llvm/22.1.1/bin/../include/c++/v1/__charconv/chars_format.h:34:53: note: candidate function not viable: no known conversion from 'std::optional<int>' to 'chars_format' for 1st argument
   34 | inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator|(chars_format __x, chars_format __y) {
      |                                                     ^         ~~~~~~~~~~~~~~~~
/usr/local/Cellar/llvm/22.1.1/bin/../include/c++/v1/bitset:941:1: note: candidate template ignored: could not match 'bitset' against 'std::optional'
  941 | operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
      | ^

. . . 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions