rnpgp / rnp

RNP: high performance C++ OpenPGP library used by Mozilla Thunderbird
https://www.rnpgp.org
Other
202 stars 55 forks source link

sexpp: clang-18: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>' #2241

Closed ronaldtse closed 5 months ago

ronaldtse commented 6 months ago

Originally reported by @maflcko, now moved to https://github.com/rnpgp/sexpp/issues/51.

This task is to update the sexpp module once https://github.com/rnpgp/sexpp/issues/51 is fixed.

Original post:

With clang-18 and libc++ compile failures are observed: (Tested via the OSS-Fuzz config)

In file included from /src/rnp/src/libsexpp/src/ext-key-format.cpp:24:
In file included from /src/rnp/src/libsexpp/include/sexpp/ext-key-format.h:26:
In file included from /usr/local/bin/../include/c++/v1/map:2529:
In file included from /usr/local/bin/../include/c++/v1/functional:526:
In file included from /usr/local/bin/../include/c++/v1/__functional/boyer_moore_searcher.h:27:
In file included from /usr/local/bin/../include/c++/v1/vector:321:
In file included from /usr/local/bin/../include/c++/v1/__format/formatter_bool.h:20:
In file included from /usr/local/bin/../include/c++/v1/__format/formatter_integral.h:21:
In file included from /usr/local/bin/../include/c++/v1/__format/formatter_output.h:22:
In file included from /usr/local/bin/../include/c++/v1/__format/parser_std_format_spec.h:39:
/usr/local/bin/../include/c++/v1/string:2374:20: error: incomplete definition of type 'std::char_traits<unsigned char>'
 2374 |         traits_type::copy(std::__to_address(__p) + __n_copy + __n_add,
      |         ~~~~~~~~~~~^~
/usr/local/bin/../include/c++/v1/string:2410:5: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
 2410 |     traits_type::copy(std::__to_address(__p), __s, __n);
      |     ^
/usr/local/bin/../include/c++/v1/string:2495:16: note: in instantiation of function template specialization 'std::basic_string<unsigned char>::__assign_no_alias<true>' requested here
 2495 |         return __assign_no_alias<true>(__str.data(), __str.size());
      |                ^
/src/rnp/src/libsexpp/include/sexpp/sexp.h:104:26: note: in instantiation of member function 'std::basic_string<unsigned char>::operator=' requested here
  104 | class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public std::basic_string<octet_t>,
      |                          ^
/usr/local/bin/../include/c++/v1/__fwd/string.h:23:29: note: template is declared here
   23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
      |                             ^

Could it make sense to update the submodule in src/libsexpp to provide an specialization of char_traits for unsigned char, or maybe it would be easier to use one of the pre-defined char_traits?

diff --git a/include/sexpp/sexp.h b/include/sexpp/sexp.h
index bb6ae4e..55e0c67 100644
--- a/include/sexpp/sexp.h
+++ b/include/sexpp/sexp.h
@@ -99,7 +99,7 @@ class sexp_input_stream_t;
  * SEXP simple string
  */

-typedef uint8_t octet_t;
+typedef char octet_t;

 class SEXP_PUBLIC_SYMBOL sexp_simple_string_t : public std::basic_string<octet_t>,
                                                 private sexp_char_defs_t {

Edit: Context: