test/streams_tests.cpp fails to compile on SunOS / illumos #29884

issue hebasto openend this issue on April 15, 2024
  1. hebasto commented at 9:02 pm on April 15, 2024: member

    While testing bitcoin/bitcoin#29484, which seems not related to this bug, I’ve notice the following failure:

      0$ ./autogen.sh
      1$ ./configure
      2$ gmake -C src test/test_bitcoin
      3...
      4  CXX      test/test_bitcoin-streams_tests.o
      5In file included from test/streams_tests.cpp:5:
      6./streams.h: In instantiation of 'SpanReader& SpanReader::operator>>(T&&) [with T = signed char&]':
      7test/streams_tests.cpp:148:15:   required from here
      8./streams.h:114:22: error: no matching function for call to 'Unserialize(SpanReader&, signed char&)'
      9  114 |         ::Unserialize(*this, obj);
     10      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     11In file included from ./streams.h:9:
     12./serialize.h:284:48: note: candidate: 'template<class Stream, class V>  requires  CharNotInt8<V> void Unserialize(Stream&, V)' (deleted)
     13  284 | template <typename Stream, CharNotInt8 V> void Unserialize(Stream&, V) = delete; // char serialization forbidden. Use uint8_t or int8_t
     14      |                                                ^~~~~~~~~~~
     15./serialize.h:284:48: note:   template argument deduction/substitution failed:
     16./serialize.h:284:48: note: constraints not satisfied
     17In file included from /usr/gcc/13/include/c++/13.2.0/compare:37,
     18                 from /usr/gcc/13/include/c++/13.2.0/bits/stl_pair.h:65,
     19                 from /usr/gcc/13/include/c++/13.2.0/bits/stl_algobase.h:64,
     20                 from /usr/gcc/13/include/c++/13.2.0/algorithm:60,
     21                 from ./prevector.h:13,
     22                 from ./serialize.h:12:
     23/usr/gcc/13/include/c++/13.2.0/concepts: In substitution of 'template<class Stream, class V>  requires  CharNotInt8<V> void Unserialize(Stream&, V) [with Stream = SpanReader; V = signed char]':
     24./streams.h:114:22:   required from 'SpanReader& SpanReader::operator>>(T&&) [with T = signed char&]'
     25test/streams_tests.cpp:148:15:   required from here
     26/usr/gcc/13/include/c++/13.2.0/concepts:57:15:   required for the satisfaction of '__same_as<_Tp, _Up>' [with _Tp = signed char; _Up = char]
     27/usr/gcc/13/include/c++/13.2.0/concepts:62:13:   required for the satisfaction of 'same_as<T, char>' [with T = signed char]
     28./serialize.h:268:9:   required for the satisfaction of 'CharNotInt8<V>' [with V = signed char]
     29/usr/gcc/13/include/c++/13.2.0/concepts:57:32: note: the expression 'is_same_v<_Tp, _Up> [with _Tp = signed char; _Up = char]' evaluated to 'false'
     30   57 |       concept __same_as = std::is_same_v<_Tp, _Up>;
     31      |                           ~~~~~^~~~~~~~~~~~~~~~~~~
     32./streams.h: In instantiation of 'SpanReader& SpanReader::operator>>(T&&) [with T = signed char&]':
     33test/streams_tests.cpp:148:15:   required from here
     34./serialize.h:285:33: note: candidate: 'template<class Stream> void Unserialize(Stream&, std::byte&)'
     35  285 | template <typename Stream> void Unserialize(Stream& s, std::byte& a) { a = std::byte{ser_readdata8(s)}; }
     36      |                                 ^~~~~~~~~~~
     37./serialize.h:285:33: note:   template argument deduction/substitution failed:
     38./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'std::byte&'
     39  114 |         ::Unserialize(*this, obj);
     40      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     41./serialize.h:286:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, int8_t&)'
     42  286 | template<typename Stream> inline void Unserialize(Stream& s, int8_t& a  ) { a = ser_readdata8(s); }
     43      |                                       ^~~~~~~~~~~
     44./serialize.h:286:39: note:   template argument deduction/substitution failed:
     45./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'int8_t&' {aka 'char&'}
     46  114 |         ::Unserialize(*this, obj);
     47      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     48./serialize.h:287:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, uint8_t&)'
     49  287 | template<typename Stream> inline void Unserialize(Stream& s, uint8_t& a ) { a = ser_readdata8(s); }
     50      |                                       ^~~~~~~~~~~
     51./serialize.h:287:39: note:   template argument deduction/substitution failed:
     52./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'uint8_t&' {aka 'unsigned char&'}
     53  114 |         ::Unserialize(*this, obj);
     54      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     55./serialize.h:288:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, int16_t&)'
     56  288 | template<typename Stream> inline void Unserialize(Stream& s, int16_t& a ) { a = ser_readdata16(s); }
     57      |                                       ^~~~~~~~~~~
     58./serialize.h:288:39: note:   template argument deduction/substitution failed:
     59./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'int16_t&' {aka 'short int&'}
     60  114 |         ::Unserialize(*this, obj);
     61      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     62./serialize.h:289:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, uint16_t&)'
     63  289 | template<typename Stream> inline void Unserialize(Stream& s, uint16_t& a) { a = ser_readdata16(s); }
     64      |                                       ^~~~~~~~~~~
     65./serialize.h:289:39: note:   template argument deduction/substitution failed:
     66./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'uint16_t&' {aka 'short unsigned int&'}
     67  114 |         ::Unserialize(*this, obj);
     68      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     69./serialize.h:290:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, int32_t&)'
     70  290 | template<typename Stream> inline void Unserialize(Stream& s, int32_t& a ) { a = ser_readdata32(s); }
     71      |                                       ^~~~~~~~~~~
     72./serialize.h:290:39: note:   template argument deduction/substitution failed:
     73./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'int32_t&' {aka 'int&'}
     74  114 |         ::Unserialize(*this, obj);
     75      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     76./serialize.h:291:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, uint32_t&)'
     77  291 | template<typename Stream> inline void Unserialize(Stream& s, uint32_t& a) { a = ser_readdata32(s); }
     78      |                                       ^~~~~~~~~~~
     79./serialize.h:291:39: note:   template argument deduction/substitution failed:
     80./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'uint32_t&' {aka 'unsigned int&'}
     81  114 |         ::Unserialize(*this, obj);
     82      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     83./serialize.h:292:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, int64_t&)'
     84  292 | template<typename Stream> inline void Unserialize(Stream& s, int64_t& a ) { a = ser_readdata64(s); }
     85      |                                       ^~~~~~~~~~~
     86./serialize.h:292:39: note:   template argument deduction/substitution failed:
     87./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'int64_t&' {aka 'long int&'}
     88  114 |         ::Unserialize(*this, obj);
     89      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     90./serialize.h:293:39: note: candidate: 'template<class Stream> void Unserialize(Stream&, uint64_t&)'
     91  293 | template<typename Stream> inline void Unserialize(Stream& s, uint64_t& a) { a = ser_readdata64(s); }
     92      |                                       ^~~~~~~~~~~
     93./serialize.h:293:39: note:   template argument deduction/substitution failed:
     94./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'uint64_t&' {aka 'long unsigned int&'}
     95  114 |         ::Unserialize(*this, obj);
     96      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
     97./serialize.h:294:53: note: candidate: 'template<class Stream, class B, int N>  requires  BasicByte<B> void Unserialize(Stream&, B (&)[N])'
     98  294 | template <typename Stream, BasicByte B, int N> void Unserialize(Stream& s, B (&a)[N]) { s.read(MakeWritableByteSpan(a)); }
     99      |                                                     ^~~~~~~~~~~
    100./serialize.h:294:53: note:   template argument deduction/substitution failed:
    101./streams.h:114:22: note:   mismatched types 'B [N]' and 'signed char'
    102  114 |         ::Unserialize(*this, obj);
    103      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    104./serialize.h:295:61: note: candidate: 'template<class Stream, class B, long unsigned int N>  requires  BasicByte<B> void Unserialize(Stream&, std::array<_Tp, _Nm>&)'
    105  295 | template <typename Stream, BasicByte B, std::size_t N> void Unserialize(Stream& s, std::array<B, N>& a) { s.read(MakeWritableByteSpan(a)); }
    106      |                                                             ^~~~~~~~~~~
    107./serialize.h:295:61: note:   template argument deduction/substitution failed:
    108./streams.h:114:22: note:   mismatched types 'std::array<_Tp, _Nm>' and 'signed char'
    109  114 |         ::Unserialize(*this, obj);
    110      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    111./serialize.h:296:46: note: candidate: 'template<class Stream, class B>  requires  BasicByte<B> void Unserialize(Stream&, Span<O>)'
    112  296 | template <typename Stream, BasicByte B> void Unserialize(Stream& s, Span<B> span) { s.read(AsWritableBytes(span)); }
    113      |                                              ^~~~~~~~~~~
    114./serialize.h:296:46: note:   template argument deduction/substitution failed:
    115./streams.h:114:22: note:   mismatched types 'Span<O>' and 'signed char'
    116  114 |         ::Unserialize(*this, obj);
    117      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    118./serialize.h:299:40: note: candidate: 'template<class Stream> void Unserialize(Stream&, bool&)'
    119  299 | template <typename Stream> inline void Unserialize(Stream& s, bool& a) { uint8_t f = ser_readdata8(s); a = f; }
    120      |                                        ^~~~~~~~~~~
    121./serialize.h:299:40: note:   template argument deduction/substitution failed:
    122./streams.h:114:22: note:   cannot convert 'obj' (type 'signed char') to type 'bool&'
    123  114 |         ::Unserialize(*this, obj);
    124      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    125./serialize.h:809:6: note: candidate: 'template<class Stream, class C> void Unserialize(Stream&, std::__cxx11::basic_string<C>&)'
    126  809 | void Unserialize(Stream& is, std::basic_string<C>& str)
    127      |      ^~~~~~~~~~~
    128./serialize.h:809:6: note:   template argument deduction/substitution failed:
    129./streams.h:114:22: note:   mismatched types 'std::__cxx11::basic_string<C>' and 'signed char'
    130  114 |         ::Unserialize(*this, obj);
    131      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    132./serialize.h:835:6: note: candidate: 'template<class Stream, unsigned int N, class T> void Unserialize(Stream&, prevector<N, T>&)'
    133  835 | void Unserialize(Stream& is, prevector<N, T>& v)
    134      |      ^~~~~~~~~~~
    135./serialize.h:835:6: note:   template argument deduction/substitution failed:
    136./streams.h:114:22: note:   mismatched types 'prevector<N, T>' and 'signed char'
    137  114 |         ::Unserialize(*this, obj);
    138      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    139./serialize.h:878:6: note: candidate: 'template<class Stream, class T, class A> void Unserialize(Stream&, std::vector<_ValT, _Allocator>&)'
    140  878 | void Unserialize(Stream& is, std::vector<T, A>& v)
    141      |      ^~~~~~~~~~~
    142./serialize.h:878:6: note:   template argument deduction/substitution failed:
    143./streams.h:114:22: note:   mismatched types 'std::vector<_ValT, _Allocator>' and 'signed char'
    144  114 |         ::Unserialize(*this, obj);
    145      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    146./serialize.h:908:6: note: candidate: 'template<class Stream, class K, class T> void Unserialize(Stream&, std::pair<_Tp1, _Tp2>&)'
    147  908 | void Unserialize(Stream& is, std::pair<K, T>& item)
    148      |      ^~~~~~~~~~~
    149./serialize.h:908:6: note:   template argument deduction/substitution failed:
    150./streams.h:114:22: note:   mismatched types 'std::pair<_Tp1, _Tp2>' and 'signed char'
    151  114 |         ::Unserialize(*this, obj);
    152      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    153./serialize.h:928:6: note: candidate: 'template<class Stream, class K, class T, class Pred, class A> void Unserialize(Stream&, std::map<K, T, Pred, A>&)'
    154  928 | void Unserialize(Stream& is, std::map<K, T, Pred, A>& m)
    155      |      ^~~~~~~~~~~
    156./serialize.h:928:6: note:   template argument deduction/substitution failed:
    157./streams.h:114:22: note:   mismatched types 'std::map<K, T, Pred, A>' and 'signed char'
    158  114 |         ::Unserialize(*this, obj);
    159      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    160./serialize.h:955:6: note: candidate: 'template<class Stream, class K, class Pred, class A> void Unserialize(Stream&, std::set<K, Pred, A>&)'
    161  955 | void Unserialize(Stream& is, std::set<K, Pred, A>& m)
    162      |      ^~~~~~~~~~~
    163./serialize.h:955:6: note:   template argument deduction/substitution failed:
    164./streams.h:114:22: note:   mismatched types 'std::set<K, Pred, A>' and 'signed char'
    165  114 |         ::Unserialize(*this, obj);
    166      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    167./serialize.h:997:6: note: candidate: 'template<class Stream, class T> void Unserialize(Stream&, std::shared_ptr<const T>&)'
    168  997 | void Unserialize(Stream& is, std::shared_ptr<const T>& p)
    169      |      ^~~~~~~~~~~
    170./serialize.h:997:6: note:   template argument deduction/substitution failed:
    171./streams.h:114:22: note:   mismatched types 'std::shared_ptr<const T>' and 'signed char'
    172  114 |         ::Unserialize(*this, obj);
    173      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    174./serialize.h:980:6: note: candidate: 'template<class Stream, class T> void Unserialize(Stream&, std::unique_ptr<const T>&)'
    175  980 | void Unserialize(Stream& is, std::unique_ptr<const T>& p)
    176      |      ^~~~~~~~~~~
    177./serialize.h:980:6: note:   template argument deduction/substitution failed:
    178./streams.h:114:22: note:   mismatched types 'std::unique_ptr<const T>' and 'signed char'
    179  114 |         ::Unserialize(*this, obj);
    180      |         ~~~~~~~~~~~~~^~~~~~~~~~~~
    181./serialize.h:774:6: note: candidate: 'template<class Stream, class T>  requires  Unserializable<T, Stream> void Unserialize(Stream&, T&&)'
    182  774 | void Unserialize(Stream& is, T&& a)
    183      |      ^~~~~~~~~~~
    184./serialize.h:774:6: note:   template argument deduction/substitution failed:
    185./serialize.h:774:6: note: constraints not satisfied
    186./serialize.h: In substitution of 'template<class Stream, class T>  requires  Unserializable<T, Stream> void Unserialize(Stream&, T&&) [with Stream = SpanReader; T = signed char&]':
    187./streams.h:114:22:   required from 'SpanReader& SpanReader::operator>>(T&&) [with T = signed char&]'
    188test/streams_tests.cpp:148:15:   required from here
    189./serialize.h:771:9:   required for the satisfaction of 'Unserializable<T, Stream>' [with T = signed char&; Stream = SpanReader]
    190./serialize.h:771:26:   in requirements with 'T a', 'Stream s' [with T = signed char&; Stream = SpanReader]
    191./serialize.h:771:65: note: the required expression 'a.Unserialize(s)' is invalid
    192  771 | concept Unserializable = requires(T a, Stream s) { a.Unserialize(s); };
    193      |                                                    ~~~~~~~~~~~~~^~~
    194./streams.h: In instantiation of 'SpanReader& SpanReader::operator>>(T&&) [with T = signed char&]':
    195test/streams_tests.cpp:148:15:   required from here
    196...
    

    I believe, it has been broken since #12254.


    System and compiler details:

    0$ uname -a
    1SunOS openindiana 5.11 illumos-064d431af1 i86pc i386 i86pc
    2$ g++ --version
    3g++ (OpenIndiana 13.2.0-oi-3) 13.2.0
    4Copyright (C) 2023 Free Software Foundation, Inc.
    5This is free software; see the source for copying conditions.  There is NO
    6warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  2. hebasto added the label Bug on Apr 15, 2024
  3. hebasto added the label Build system on Apr 15, 2024
  4. hebasto added the label Linux/Unix on Apr 15, 2024
  5. maflcko commented at 7:37 am on April 16, 2024: member

    Using char is not allowed in serialization code, because the sign of char is unknown/unclear. However, on some systems, int8_t==char, which means that signed char has no serialization helper.

    This could be fixed in the serialization code by replacing int8_t by a concept of !CharNotInt8 || std::same_as<T, signed char>. However, my preference would be to completely avoid signed char and just use int8_t in the serialization code. That is, fix the test to use int8_t.

  6. hebasto commented at 8:53 am on April 16, 2024: member

    However, my preference would be to completely avoid signed char and just use int8_t in the serialization code. That is, fix the test to use int8_t.

    I lean to agree, considering that signed char is used in tests only.

  7. maflcko commented at 9:04 am on April 16, 2024: member
    Happy to review a pull, if someone creates one.
  8. hebasto commented at 8:31 pm on April 18, 2024: member

    Happy to review a pull, if someone creates one.

    Please see #29907.

  9. fanquake closed this on May 4, 2024

  10. fanquake referenced this in commit 61d3280c3a on May 4, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-03 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me