Skip to content

Commit 2763f04

Browse files
Merge pull request #90 from DmitriiKuchevskii/GCC-10-build
Fixed complation issues and warnings to build with GCC-10
2 parents ec48b01 + 8dd876d commit 2763f04

11 files changed

+33
-27
lines changed

src/mfast/aggregate_ref.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ template <typename ConstRef> class make_aggregate_mref : public ConstRef {
125125
instruction_cptr instruction);
126126

127127
explicit make_aggregate_mref(const field_mref_base &other);
128+
explicit make_aggregate_mref(const make_aggregate_mref &other) = default;
128129

129130
field_mref operator[](size_t index) const;
130131

src/mfast/coder/encoder/fast_encoder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ struct fast_encoder_impl : simple_template_repo_t {
5050
}
5151

5252
void visit(enum_cref cref) {
53-
uint64_cref tmp;
54-
std::memcpy(&tmp, &cref, sizeof(cref));
53+
uint64_cref tmp{cref};
5554
this->visit(tmp);
5655
}
5756

src/mfast/instructions/group_instruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void group_field_instruction::construct_value(value_storage &storage,
8686
if (construct_subfields)
8787
construct_group_subfields(storage.of_group.content_, alloc);
8888
else
89-
memset(storage.of_group.content_, 0, this->group_content_byte_count());
89+
memset(reinterpret_cast<char*>(storage.of_group.content_), 0, this->group_content_byte_count());
9090
}
9191

9292
void group_field_instruction::copy_construct_value(

src/mfast/instructions/templateref_instruction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void templateref_instruction::construct_value(
2929
from_inst->construct_group_subfields(storage.of_templateref.content_,
3030
alloc);
3131
else
32-
memset(storage.of_templateref.content_, 0,
33-
from_inst->group_content_byte_count());
32+
memset(reinterpret_cast<char*>(storage.of_templateref.content_), 0,
33+
from_inst->group_content_byte_count());
3434
} else {
3535
storage.of_templateref.content_ = nullptr;
3636
}

src/mfast/value_storage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdint.h>
1010
#include <cstring>
1111
#include <array>
12+
#include <istream>
1213

1314
namespace mfast {
1415
class template_instruction;

src/mfast/vector_ref.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class vector_cref_base : public field_cref {
4040
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
4141

4242
vector_cref_base() {}
43+
explicit vector_cref_base (const vector_cref_base&) = default;
4344
vector_cref_base(const value_storage *storage, instruction_cptr instruction)
4445
: field_cref(storage, instruction) {}
4546

tests/decoder_operator_test.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ TEST_CASE("test the decoding of fast operator copy","[operator_copy_decode_test]
497497
inst.prev_value().present(false); // // When the value is not present in the stream there are three cases depending on the state of the previous value:
498498
// // * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory.
499499

500-
REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), mfast::fast_error );
500+
REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error& );
501501
inst.prev_value().present(false);
502-
REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref<uint64_mref, copy_operator_tag, mandatory_with_initial_value_tag >(result), CHANGE_PREVIOUS_VALUE), mfast::fast_error );
502+
REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref<uint64_mref, copy_operator_tag, mandatory_with_initial_value_tag >(result), CHANGE_PREVIOUS_VALUE), const mfast::fast_error& );
503503
}
504504

505505
{
@@ -644,8 +644,8 @@ TEST_CASE("test the decoding of fast operator increment","[operator_increment_de
644644
inst.prev_value().present(false);
645645
// When the value is not present in the stream there are three cases depending on the state of the previous value:
646646
// * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory.
647-
REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), mfast::fast_error);
648-
REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref<uint64_mref, increment_operator_tag, mandatory_with_initial_value_tag >(result), CHANGE_PREVIOUS_VALUE), mfast::fast_error);
647+
REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error&);
648+
REQUIRE_THROWS_AS(decode_ext_mref("\x80\x80", HAS_PMAP_BIT, ext_mref<uint64_mref, increment_operator_tag, mandatory_with_initial_value_tag >(result), CHANGE_PREVIOUS_VALUE), const mfast::fast_error&);
649649
}
650650

651651
{
@@ -980,10 +980,10 @@ TEST_CASE("test the decoding of fast operator delta for ascii string","[operator
980980
REQUIRE_THROWS_AS(decode_mref("\xC0\x86\x76\x61\x6C\x75\xE5",
981981
NO_PMAP_BIT,
982982
result,
983-
CHANGE_PREVIOUS_VALUE), mfast::fast_error);
983+
CHANGE_PREVIOUS_VALUE), const mfast::fast_error&);
984984
inst.prev_value().defined(false); // reset the previous value to undefined again
985985
REQUIRE_THROWS_AS(decode_ext_mref("\xC0\x86\x76\x61\x6C\x75\xE5", NO_PMAP_BIT, ext_mref<ascii_string_mref, delta_operator_tag, mandatory_without_initial_value_tag >(
986-
result), CHANGE_PREVIOUS_VALUE), mfast::fast_error);
986+
result), CHANGE_PREVIOUS_VALUE), const mfast::fast_error&);
987987

988988
inst.destruct_value(storage, &alloc);
989989
}
@@ -1117,10 +1117,10 @@ TEST_CASE("test the decoding of fast operator delta for unicode string","[operat
11171117

11181118
// result.as("initial_value");
11191119
REQUIRE_THROWS_AS(decode_mref("\xC0\x86\x85\x76\x61\x6C\x75\x65", NO_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE),
1120-
mfast::fast_error );
1120+
const mfast::fast_error& );
11211121
REQUIRE_THROWS_AS(decode_ext_mref("\xC0\x86\x85\x76\x61\x6C\x75\x65", NO_PMAP_BIT,
11221122
ext_mref<unicode_string_mref, delta_operator_tag, mandatory_without_initial_value_tag >(result), CHANGE_PREVIOUS_VALUE),
1123-
mfast::fast_error );
1123+
const mfast::fast_error& );
11241124
inst.destruct_value(storage, &alloc);
11251125
}
11261126

@@ -1224,7 +1224,7 @@ TEST_CASE("test the decoding of fast operator tail for ascii string","[operator_
12241224
// undefined – the base value is the initial value if present in the instruction context. Otherwise a type dependant default base value is used.
12251225
result.as("initial_string");
12261226
REQUIRE(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE) );
1227-
memset(const_cast<value_storage*>(&inst.prev_value()), 0, sizeof(value_storage));
1227+
memset(reinterpret_cast<char*>(const_cast<value_storage*>(&inst.prev_value())) , 0, sizeof(value_storage));
12281228
ascii_string_mref prev(&alloc, &inst.prev_value(), &inst);
12291229

12301230
// change the previous value to "ABCDE" so we can verified the case with defined previous value
@@ -1256,7 +1256,7 @@ TEST_CASE("test the decoding of fast operator tail for ascii string","[operator_
12561256
// undefined – the value of the field is the initial value that also becomes the new previous value.
12571257
// It is a dynamic error [ERR D6] if the instruction context has no initial value.
12581258

1259-
REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), mfast::fast_error );
1259+
REQUIRE_THROWS_AS(decode_mref("\x80\x80", HAS_PMAP_BIT, result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error& );
12601260

12611261
inst.destruct_value(storage, &alloc);
12621262
}

tests/encoder_operator_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,12 @@ TEST_CASE("test the encoding of fast operator copy","[operator_copy_encode_test]
528528
inst.prev_value().present(false); // // When the value is not present in the stream there are three cases depending on the state of the previous value:
529529
// // * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory.
530530

531-
REQUIRE_THROWS_AS( encode_mref("\x80", result, CHANGE_PREVIOUS_VALUE), mfast::fast_error );
531+
REQUIRE_THROWS_AS( encode_mref("\x80", result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error& );
532532
inst.prev_value().present(false); // // When the value is not present in the stream there are three cases depending on the state of the previous value:
533533
REQUIRE_THROWS_AS( encode_ext_cref("\x80",
534534
ext_cref<uint64_cref, copy_operator_tag, mandatory_with_initial_value_tag>(result),
535535
CHANGE_PREVIOUS_VALUE, &allocator )
536-
, mfast::fast_error );
536+
, const mfast::fast_error& );
537537
}
538538

539539
{
@@ -687,12 +687,12 @@ TEST_CASE("test the encoding of fast operator increment","[operator_increment_en
687687
inst.prev_value().present(false);
688688
// When the value is not present in the stream there are three cases depending on the state of the previous value:
689689
// * empty – the value of the field is empty. If the field is optional the value is considered absent. It is a dynamic error [ERR D6] if the field is mandatory.
690-
REQUIRE_THROWS_AS( encode_mref("\x80\x80", result, CHANGE_PREVIOUS_VALUE), mfast::fast_error);
690+
REQUIRE_THROWS_AS( encode_mref("\x80\x80", result, CHANGE_PREVIOUS_VALUE), const mfast::fast_error&);
691691
inst.prev_value().present(false);
692692
REQUIRE_THROWS_AS( encode_ext_cref("\x80\x80",
693693
ext_cref<uint64_cref, increment_operator_tag, mandatory_with_initial_value_tag>(result),
694694
CHANGE_PREVIOUS_VALUE, &allocator ),
695-
mfast::fast_error);
695+
const mfast::fast_error&);
696696
}
697697

698698
{

tests/fast_istream_test.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#include <stdexcept>
2626
#include "byte_stream.h"
2727

28+
template <typename T, size_t N>
29+
char (&array_size_helper(const T (&)[N]))[N];
30+
#define ARRAY_SIZE(a) sizeof(array_size_helper(a))
31+
2832
using namespace mfast;
2933

3034
template <typename T>
@@ -76,7 +80,7 @@ TEST_CASE("test the fast decoding of integers","[int32_test]")
7680

7781
{ // check decoding null
7882
char data[] = "\x80";
79-
fast_istreambuf sb(data, 3);
83+
fast_istreambuf sb(data, ARRAY_SIZE(data));
8084
fast_istream strm(&sb);
8185

8286
uint32_t value;
@@ -122,9 +126,9 @@ TEST_CASE("test the fast decoding of ascii string","[ascii_string_test]")
122126
REQUIRE(decode_string( "\x40\x40\xC0", true, "\x40\x40\xC0", 3));
123127
REQUIRE(decode_string( "\x40\x40\xC0", false, "\x40\x40\xC0", 3));
124128

125-
REQUIRE_THROWS_AS(decode_string("\x00\xC0", false, nullptr, 0), mfast::fast_error );
126-
REQUIRE_THROWS_AS(decode_string("\x00\xC0", true, nullptr, 0), mfast::fast_error );
127-
REQUIRE_THROWS_AS(decode_string("\x00\x00\xC0", true, nullptr, 0), mfast::fast_error );
129+
REQUIRE_THROWS_AS(decode_string("\x00\xC0", false, nullptr, 0), const mfast::fast_error& );
130+
REQUIRE_THROWS_AS(decode_string("\x00\xC0", true, nullptr, 0), const mfast::fast_error& );
131+
REQUIRE_THROWS_AS(decode_string("\x00\x00\xC0", true, nullptr, 0), const mfast::fast_error& );
128132
}
129133

130134
bool

tests/field_ref_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TEST_CASE("test the operations of interger_field","[integer_field_test]")
108108
#ifndef EMSCRIPTEN
109109
{
110110
helper.save_previous_value(ref);
111-
REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), mfast::fast_error);
111+
REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), const mfast::fast_error&);
112112
}
113113
#endif
114114
{
@@ -307,7 +307,7 @@ TEST_CASE("test the operations of decimal_field without mantissa instruction","[
307307
{
308308
ref.omit();
309309
helper.save_previous_value(ref);
310-
REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), mfast::fast_error);
310+
REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), const mfast::fast_error&);
311311
}
312312
#endif
313313
{
@@ -588,7 +588,7 @@ TEST_CASE("test the operations of string_field","[string_field_test]")
588588
#ifndef EMSCRIPTEN
589589
{
590590
helper.save_previous_value(ref);
591-
REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), mfast::fast_error);
591+
REQUIRE_THROWS_AS(helper.delta_base_value_of(ref), const mfast::fast_error&);
592592
}
593593
#endif
594594
{

0 commit comments

Comments
 (0)