Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::char_traits<std::byte> removed in libc++ 18 #366

Closed
Altren opened this issue Feb 27, 2025 · 3 comments
Closed

std::char_traits<std::byte> removed in libc++ 18 #366

Altren opened this issue Feb 27, 2025 · 3 comments

Comments

@Altren
Copy link
Contributor

Altren commented Feb 27, 2025

Reflect-cpp can't be compiled with XCode 16.3 because of this.
https://github.com/llvm/llvm-project/blob/release/17.x/libcxx/docs/ReleaseNotes/17.rst#llvm-18
So it seems that something like std::vectorstd::byte should be used.
I tried to do this myself, and few build issues in the library are trivial, but I don't understand what's wrong here:

In file included from /Users/gevmenov/libs/reflect-cpp/include/rfl.hpp:55:
In file included from /Users/gevmenov/libs/reflect-cpp/include/rfl/enums.hpp:7:
/Users/gevmenov/libs/reflect-cpp/include/rfl/internal/enums/StringConverter.hpp:42:19: error: static assertion failed due to requirement 'names_.size != 0': No enum could be identified. Please choose enum values between 0 to 127 or for flag enums choose 1,2,4,8,16,...
   42 |     static_assert(names_.size != 0,
      |                   ^~~~~~~~~~~~~~~~
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/Parser_default.hpp:83:32: note: in instantiation of member function 'rfl::internal::enums::StringConverter<std::byte>::string_to_enum' requested here
   83 |               StringConverter::string_to_enum);
      |                                ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/VectorReader.hpp:28:70: note: in instantiation of member function 'rfl::parsing::Parser<rfl::msgpack::Reader, rfl::msgpack::Writer, std::byte, rfl::Processors<>>::read' requested here
   28 |         return Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::read(*r_,
      |                                                                      ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/msgpack/Reader.hpp:87:38: note: in instantiation of member function 'rfl::parsing::VectorReader<rfl::msgpack::Reader, rfl::msgpack::Writer, std::vector<std::byte>, rfl::Processors<>>::read' requested here
   87 |       const auto err = _array_reader.read(_arr.ptr[i]);
      |                                      ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/VectorParser.hpp:58:29: note: in instantiation of function template specialization 'rfl::msgpack::Reader::read_array<rfl::parsing::VectorReader<rfl::msgpack::Reader, rfl::msgpack::Writer, std::vector<std::byte>, rfl::Processors<>>>' requested here
   58 |         const auto err = _r.read_array(vector_reader, _arr);
      |                             ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/ViewReader.hpp:53:51: note: in instantiation of member function 'rfl::parsing::VectorParser<rfl::msgpack::Reader, rfl::msgpack::Writer, std::vector<std::byte>, rfl::Processors<>>::read' requested here
   53 |       auto res = Parser<R, W, T, ProcessorsType>::read(_r, _var);
      |                                                   ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/ViewReader.hpp:102:6: note: in instantiation of function template specialization 'rfl::parsing::ViewReader<rfl::msgpack::Reader, rfl::msgpack::Writer, rfl::NamedTuple<rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>, rfl::Processors<>>::assign_if_field_matches<0, msgpack_object, rfl::NamedTuple<rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>, std::vector<rfl::Error>, std::array<bool, 1>, std::array<bool, 1>>' requested here
  102 |     (assign_if_field_matches<is>(_r, _current_name, _var, _view, _errors,
      |      ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/ViewReader.hpp:33:5: note: in instantiation of function template specialization 'rfl::parsing::ViewReader<rfl::msgpack::Reader, rfl::msgpack::Writer, rfl::NamedTuple<rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>, rfl::Processors<>>::assign_to_matching_field<0, msgpack_object, rfl::NamedTuple<rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>, std::vector<rfl::Error>, std::array<bool, 1>, std::array<bool, 1>>' requested here
   33 |     assign_to_matching_field(*r_, _name, _var, view_, errors_, found_, set_,
      |     ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/msgpack/Reader.hpp:106:22: note: in instantiation of member function 'rfl::parsing::ViewReader<rfl::msgpack::Reader, rfl::msgpack::Writer, rfl::NamedTuple<rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>, rfl::Processors<>>::read' requested here
  106 |       _object_reader.read(name, val);
      |                      ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/NamedTupleParser.hpp:308:16: note: in instantiation of function template specialization 'rfl::msgpack::Reader::read_object<rfl::parsing::ViewReader<rfl::msgpack::Reader, rfl::msgpack::Writer, rfl::NamedTuple<rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>, rfl::Processors<>>>' requested here
  308 |       err = _r.read_object(reader, _obj_or_arr);
      |                ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/NamedTupleParser.hpp:121:14: note: in instantiation of member function 'rfl::parsing::NamedTupleParser<rfl::msgpack::Reader, rfl::msgpack::Writer, false, true, false, rfl::Processors<>, rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>::read_object_or_array' requested here
  121 |       return read_object_or_array(_r, *obj, _view);
      |              ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/Parser_default.hpp:262:49: note: in instantiation of member function 'rfl::parsing::NamedTupleParser<rfl::msgpack::Reader, rfl::msgpack::Writer, false, true, false, rfl::Processors<>, rfl::Field<internal::StringLiteral<11>{{"bytestring"}}, std::vector<std::byte> *>>::read_view' requested here
  262 |         Parser<R, W, ViewType, ProcessorsType>::read_view(_r, _var, &view);
      |                                                 ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/generic/../parsing/Parser_default.hpp:74:18: note: in instantiation of member function 'rfl::parsing::Parser<rfl::msgpack::Reader, rfl::msgpack::Writer, test_bytestring::TestStruct, rfl::Processors<>>::read_struct' requested here
   74 |           return read_struct(_r, _var);
      |                  ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/msgpack/read.hpp:24:40: note: in instantiation of member function 'rfl::parsing::Parser<rfl::msgpack::Reader, rfl::msgpack::Writer, test_bytestring::TestStruct, rfl::Processors<>>::read' requested here
   24 |   return Parser<T, Processors<Ps...>>::read(r, _obj);
      |                                        ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/msgpack/read.hpp:43:10: note: in instantiation of function template specialization 'rfl::msgpack::read<test_bytestring::TestStruct>' requested here
   43 |   return read<T, Ps...>(_bytes.data(), _bytes.size());
      |          ^
/Users/gevmenov/libs/reflect-cpp/tests/msgpack/test_bytestring.cpp:19:3: note: in instantiation of function template specialization 'write_and_read<test_bytestring::TestStruct>' requested here
   19 |   write_and_read(test);
      |   ^
/Users/gevmenov/libs/reflect-cpp/include/rfl/internal/enums/StringConverter.hpp:42:31: note: expression evaluates to '0 != 0'
   42 |     static_assert(names_.size != 0,
      |                   ~~~~~~~~~~~~^~~~```
@Altren
Copy link
Contributor Author

Altren commented Feb 27, 2025

May be this issue is not related to the Bytestring. I'd better wait for XCode 16.3 release before getting deeper into this.

Also std::char_traits<std::byte> was removed by mistake (it should've been only marked as deprecated), and was reintroduced into llvm with this fix llvm/llvm-project@cce062d but apparently, XCode developers missed that fix.

@YBerd
Copy link

YBerd commented Mar 1, 2025

Just in case: this issue is not related to Xcode itself, it is about LLVM (clang / libc++) 19.x that xcode 16.3 is based onto.

LLVM docs

The base template for std::char_traits has been removed in LLVM 19. If you are using std::char_traits with types other than char, wchar_t, char8_t, char16_t, char32_t or a custom character type for which you specialized std::char_traits, your code will stop working. The Standard does not mandate that a base template is provided, and such a base template is bound to be incorrect for some types, which could currently cause unexpected behavior while going undetected

@Altren
Copy link
Contributor Author

Altren commented Mar 1, 2025

Fixed here: #369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants