Skip to content

Error while building with clang-21 #5

@schwarzschild-radius

Description

@schwarzschild-radius

I noticed the following template instantiation errors from test_maybe.cpp while compiling with clang-21 (developement branch - https://apt.llvm.org/)

/wormhole/libCat/src/libraries/maybe/cat/maybe:228:16: error: member reference base type 'int' is not a structure or union
  228 |       if (maybe.has_value()) {
      |           ~~~~~^~~~~~~~~~
/wormhole/libCat/src/libraries/maybe/cat/maybe:229:10: note: in instantiation of function template specialization 'cat::maybe_value_storage<int>::assign<int &>' requested here
  229 |          assign(fwd(maybe).value());
      |          ^
/wormhole/libCat/src/libraries/maybe/cat/maybe:585:17: note: in instantiation of function template specialization 'cat::maybe_value_storage<int>::assign<cat::maybe<int> &>' requested here
  585 |       m_storage.assign(input);
      |                 ^
/wormhole/libCat/tests/src/test_maybe.cpp:53:14: note: in instantiation of function template specialization 'cat::maybe<int>::maybe<int>' requested here
   53 |    int boo = prop(error);
      |              ^
/wormhole/libCat/src/global_includes.hpp:202:14: note: expanded from macro 'prop'
  202 | #define prop CAT_PROPAGATE
      |              ^
/wormhole/libCat/src/global_includes.hpp:191:31: note: expanded from macro 'CAT_PROPAGATE'
  191 |       auto libcat_temp_expr = (container); 
/wormhole/libCat/src/libraries/maybe/cat/maybe:228:17: error: no member named 'has_value' in 'cat::arithmetic<int, cat::overflow_policies::undefined>'
  228 |       if (maybe.has_value()) {
      |           ~~~~~ ^
/wormhole/libCat/src/libraries/maybe/cat/maybe:229:10: note: in instantiation of function template specialization 'cat::maybe_value_storage<cat::unique<cat::arithmetic<int, cat::overflow_policies::undefined>>>::assign<cat::arithmetic<int, cat::overflow_policies::undefined>>' requested here
  229 |          assign(fwd(maybe).value());
      |          ^
/wormhole/libCat/src/libraries/maybe/cat/maybe:676:17: note: in instantiation of function template specialization 'cat::maybe_value_storage<cat::unique<cat::arithmetic<int, cat::overflow_policies::undefined>>>::assign<cat::maybe<cat::arithmetic<int, cat::overflow_policies::undefined>>>' requested here
  676 |       m_storage.assign(move(maybe));
      |                 ^
/wormhole/libCat/tests/src/test_maybe.cpp:293:17: note: in instantiation of function template specialization 'cat::maybe<cat::unique<cat::arithmetic<int, cat::overflow_policies::undefined>>>::operator=<cat::arithmetic<int, cat::overflow_policies::undefined>>' requested here
  293 |    monadic_move = return_none(0).and_then(return_opt);
/wormhole/libCat/src/libraries/maybe/cat/maybe:228:17: error: no member named 'has_value' in 'cat::arithmetic<int, cat::overflow_policies::undefined>'
  228 |       if (maybe.has_value()) {
      |           ~~~~~ ^
/wormhole/libCat/src/libraries/maybe/cat/maybe:229:10: note: in instantiation of function template specialization 'cat::maybe_value_storage<cat::arithmetic<int, cat::overflow_policies::undefined>>::assign<cat::arithmetic<int, cat::overflow_policies::undefined> &>' requested here
  229 |          assign(fwd(maybe).value());
      |          ^
/wormhole/libCat/src/libraries/maybe/cat/maybe:585:17: note: in instantiation of function template specialization 'cat::maybe_value_storage<cat::arithmetic<int, cat::overflow_policies::undefined>>::assign<cat::maybe<cat::arithmetic<int, cat::overflow_policies::undefined>> &>' requested here
  585 |       m_storage.assign(input);
      |                 ^
/wormhole/libCat/tests/src/test_maybe.cpp:302:34: note: in instantiation of function template specialization 'cat::maybe<cat::arithmetic<int, cat::overflow_policies::undefined>>::maybe<cat::arithmetic<int, cat::overflow_policies::undefined>>' requested here
  302 |    cat::maybe<int4> opt_copy_1 = cat::maybe(opt_original);

1 I suspect is due to an implicit conversion of maybe
2 and 3 is due to a wrong overload resolution

I hacked around by constraining maybe's assign with

   // If this is assigned a `maybe` which wraps a type that can be
   // converted to `T` , then convert that storage to this type implicitly.
   template <typename other_maybe>
   requires requires (other_maybe x) { x.has_value(); }
   constexpr void

which fixes the build failures. Maybe (pun intended) there is a different solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions