Skip to content

Commit bf59ba7

Browse files
jkeiserlemire
authored andcommitted
Fix most warnings on VS2019 (simdjson#241)
1 parent e8e78f8 commit bf59ba7

13 files changed

+63
-62
lines changed

benchmark/parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ int main(int argc, char *argv[]) {
166166
simdjson::padded_string p;
167167
try {
168168
simdjson::get_corpus(filename).swap(p);
169-
} catch (const std::exception &e) { // caught by reference to base
169+
} catch (const std::exception &) { // caught by reference to base
170170
std::cout << "Could not load the file " << filename << std::endl;
171171
return EXIT_FAILURE;
172172
}

benchmark/statisticalmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int main(int argc, char *argv[]) {
138138
simdjson::padded_string p;
139139
try {
140140
simdjson::get_corpus(filename).swap(p);
141-
} catch (const std::exception &e) { // caught by reference to base
141+
} catch (const std::exception &) { // caught by reference to base
142142
std::cerr << "Could not load the file " << filename << std::endl;
143143
return EXIT_FAILURE;
144144
}

include/simdjson/parsedjson.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "simdjson/simdjson.h"
88
#include <cinttypes>
99
#include <cmath>
10+
#include <limits>
1011
#include <cstring>
1112
#include <iomanip>
1213
#include <iostream>
@@ -107,9 +108,9 @@ class ParsedJson {
107108
explicit Iterator(ParsedJson &pj_);
108109
~Iterator();
109110

110-
Iterator(const Iterator &o);
111+
Iterator(const Iterator &o) noexcept;
111112

112-
Iterator(Iterator &&o);
113+
Iterator(Iterator &&o) noexcept;
113114

114115
inline bool is_ok() const;
115116

@@ -167,7 +168,7 @@ class ParsedJson {
167168
// we're at "d"
168169
inline double get_double() const {
169170
if (location + 1 >= tape_length) {
170-
return NAN; // default value in case of error
171+
return std::numeric_limits<double>::quiet_NaN(); // default value in case of error
171172
}
172173
double answer;
173174
memcpy(&answer, &pj.tape[location + 1], sizeof(answer));

include/simdjson/simdutf8check_haswell.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static inline void avx_check_smaller_than_0xF4(__m256i current_bytes,
4141
__m256i *has_error) {
4242
// unsigned, saturates to 0 below max
4343
*has_error = _mm256_or_si256(
44-
*has_error, _mm256_subs_epu8(current_bytes, _mm256_set1_epi8(0xF4)));
44+
*has_error, _mm256_subs_epu8(current_bytes, _mm256_set1_epi8(0xF4u)));
4545
}
4646

4747
static inline __m256i avx_continuation_lengths(__m256i high_nibbles) {
@@ -94,14 +94,14 @@ static inline void avx_check_first_continuation_max(__m256i current_bytes,
9494
__m256i off1_current_bytes,
9595
__m256i *has_error) {
9696
__m256i maskED =
97-
_mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xED));
97+
_mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xEDu));
9898
__m256i maskF4 =
99-
_mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xF4));
99+
_mm256_cmpeq_epi8(off1_current_bytes, _mm256_set1_epi8(0xF4u));
100100

101101
__m256i badfollowED = _mm256_and_si256(
102-
_mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x9F)), maskED);
102+
_mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x9Fu)), maskED);
103103
__m256i badfollowF4 = _mm256_and_si256(
104-
_mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x8F)), maskF4);
104+
_mm256_cmpgt_epi8(current_bytes, _mm256_set1_epi8(0x8Fu)), maskF4);
105105

106106
*has_error =
107107
_mm256_or_si256(*has_error, _mm256_or_si256(badfollowED, badfollowF4));
@@ -119,31 +119,31 @@ static inline void avx_check_overlong(__m256i current_bytes,
119119
__m256i *has_error) {
120120
__m256i off1_hibits = push_last_byte_of_a_to_b(previous_hibits, hibits);
121121
__m256i initial_mins = _mm256_shuffle_epi8(
122-
_mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128,
123-
-128, -128, -128, // 10xx => false
124-
0xC2, -128, // 110x
125-
0xE1, // 1110
126-
0xF1, // 1111
127-
-128, -128, -128, -128, -128, -128, -128, -128, -128,
128-
-128, -128, -128, // 10xx => false
129-
0xC2, -128, // 110x
130-
0xE1, // 1110
131-
0xF1), // 1111
122+
_mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128,
123+
-128, -128, -128, // 10xx => false
124+
0xC2u, -128, // 110x
125+
0xE1u, // 1110
126+
0xF1u, // 1111
127+
-128, -128, -128, -128, -128, -128, -128, -128, -128,
128+
-128, -128, -128, // 10xx => false
129+
0xC2u, -128, // 110x
130+
0xE1u, // 1110
131+
0xF1u), // 1111
132132
off1_hibits);
133133

134134
__m256i initial_under = _mm256_cmpgt_epi8(initial_mins, off1_current_bytes);
135135

136136
__m256i second_mins = _mm256_shuffle_epi8(
137-
_mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128,
138-
-128, -128, -128, // 10xx => false
139-
127, 127, // 110x => true
140-
0xA0, // 1110
141-
0x90, // 1111
142-
-128, -128, -128, -128, -128, -128, -128, -128, -128,
143-
-128, -128, -128, // 10xx => false
144-
127, 127, // 110x => true
145-
0xA0, // 1110
146-
0x90), // 1111
137+
_mm256_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128,
138+
-128, -128, -128, // 10xx => false
139+
127, 127, // 110x => true
140+
0xA0u, // 1110
141+
0x90u, // 1111
142+
-128, -128, -128, -128, -128, -128, -128, -128, -128,
143+
-128, -128, -128, // 10xx => false
144+
127, 127, // 110x => true
145+
0xA0u, // 1110
146+
0x90u), // 1111
147147
off1_hibits);
148148
__m256i second_under = _mm256_cmpgt_epi8(second_mins, current_bytes);
149149
*has_error = _mm256_or_si256(*has_error,

include/simdjson/simdutf8check_westmere.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static inline void check_smaller_than_0xF4(__m128i current_bytes,
3535
__m128i *has_error) {
3636
// unsigned, saturates to 0 below max
3737
*has_error = _mm_or_si128(*has_error,
38-
_mm_subs_epu8(current_bytes, _mm_set1_epi8(0xF4)));
38+
_mm_subs_epu8(current_bytes, _mm_set1_epi8(0xF4u)));
3939
}
4040

4141
static inline __m128i continuation_lengths(__m128i high_nibbles) {
@@ -80,13 +80,13 @@ static inline void check_continuations(__m128i initial_lengths, __m128i carries,
8080
static inline void check_first_continuation_max(__m128i current_bytes,
8181
__m128i off1_current_bytes,
8282
__m128i *has_error) {
83-
__m128i maskED = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xED));
84-
__m128i maskF4 = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xF4));
83+
__m128i maskED = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xEDu));
84+
__m128i maskF4 = _mm_cmpeq_epi8(off1_current_bytes, _mm_set1_epi8(0xF4u));
8585

8686
__m128i badfollowED =
87-
_mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x9F)), maskED);
87+
_mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x9Fu)), maskED);
8888
__m128i badfollowF4 =
89-
_mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x8F)), maskF4);
89+
_mm_and_si128(_mm_cmpgt_epi8(current_bytes, _mm_set1_epi8(0x8Fu)), maskF4);
9090

9191
*has_error = _mm_or_si128(*has_error, _mm_or_si128(badfollowED, badfollowF4));
9292
}
@@ -102,21 +102,21 @@ static inline void check_overlong(__m128i current_bytes,
102102
__m128i previous_hibits, __m128i *has_error) {
103103
__m128i off1_hibits = _mm_alignr_epi8(hibits, previous_hibits, 16 - 1);
104104
__m128i initial_mins = _mm_shuffle_epi8(
105-
_mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
106-
-128, -128, // 10xx => false
107-
0xC2, -128, // 110x
108-
0xE1, // 1110
109-
0xF1),
105+
_mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
106+
-128, -128, // 10xx => false
107+
0xC2u, -128, // 110x
108+
0xE1u, // 1110
109+
0xF1u),
110110
off1_hibits);
111111

112112
__m128i initial_under = _mm_cmpgt_epi8(initial_mins, off1_current_bytes);
113113

114114
__m128i second_mins = _mm_shuffle_epi8(
115-
_mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
116-
-128, -128, // 10xx => false
117-
127, 127, // 110x => true
118-
0xA0, // 1110
119-
0x90),
115+
_mm_setr_epi8(-128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
116+
-128, -128, // 10xx => false
117+
127, 127, // 110x => true
118+
0xA0u, // 1110
119+
0x90u),
120120
off1_hibits);
121121
__m128i second_under = _mm_cmpgt_epi8(second_mins, current_bytes);
122122
*has_error =

include/simdjson/stage1_find_marks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace simdjson {
1111

1212
template <Architecture> struct simd_input;
1313

14-
template <Architecture T> uint64_t compute_quote_mask(uint64_t quote_bits);
14+
template <Architecture> uint64_t compute_quote_mask(uint64_t quote_bits);
1515

1616
namespace {
1717
// for when clmul is unavailable

include/simdjson/stage1_find_marks_haswell.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ compute_quote_mask<Architecture::HASWELL>(uint64_t quote_bits) {
3030
// There should be no such thing with a processing supporting avx2
3131
// but not clmul.
3232
uint64_t quote_mask = _mm_cvtsi128_si64(_mm_clmulepi64_si128(
33-
_mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFF), 0));
33+
_mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFFu), 0));
3434
return quote_mask;
3535
}
3636

@@ -49,7 +49,7 @@ template <>
4949
really_inline void check_utf8<Architecture::HASWELL>(
5050
simd_input<Architecture::HASWELL> in,
5151
utf8_checking_state<Architecture::HASWELL> &state) {
52-
__m256i high_bit = _mm256_set1_epi8(0x80);
52+
__m256i high_bit = _mm256_set1_epi8(0x80u);
5353
if ((_mm256_testz_si256(_mm256_or_si256(in.lo, in.hi), high_bit)) == 1) {
5454
// it is ascii, we just check continuation
5555
state.has_error = _mm256_or_si256(
@@ -170,12 +170,12 @@ really_inline void find_whitespace_and_structurals<Architecture::HASWELL>(
170170

171171
#else // SIMDJSON_NAIVE_STRUCTURAL
172172
const __m256i structural_table =
173-
_mm256_setr_epi8(44, 125, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123,
174-
44, 125, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123);
173+
_mm256_setr_epi8(44, 125, 0, 0, 0xc0u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123,
174+
44, 125, 0, 0, 0xc0u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123);
175175
const __m256i white_table = _mm256_setr_epi8(
176176
32, 100, 100, 100, 17, 100, 113, 2, 100, 9, 10, 112, 100, 13, 100, 100,
177177
32, 100, 100, 100, 17, 100, 113, 2, 100, 9, 10, 112, 100, 13, 100, 100);
178-
const __m256i struct_offset = _mm256_set1_epi8(0xd4);
178+
const __m256i struct_offset = _mm256_set1_epi8(0xd4u);
179179
const __m256i struct_mask = _mm256_set1_epi8(32);
180180

181181
__m256i lo_white =

include/simdjson/stage1_find_marks_westmere.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ template <>
3232
really_inline uint64_t
3333
compute_quote_mask<Architecture::WESTMERE>(uint64_t quote_bits) {
3434
return _mm_cvtsi128_si64(_mm_clmulepi64_si128(
35-
_mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFF), 0));
35+
_mm_set_epi64x(0ULL, quote_bits), _mm_set1_epi8(0xFFu), 0));
3636
}
3737

3838
template <> struct utf8_checking_state<Architecture::WESTMERE> {
@@ -48,7 +48,7 @@ template <>
4848
really_inline void check_utf8<Architecture::WESTMERE>(
4949
simd_input<Architecture::WESTMERE> in,
5050
utf8_checking_state<Architecture::WESTMERE> &state) {
51-
__m128i high_bit = _mm_set1_epi8(0x80);
51+
__m128i high_bit = _mm_set1_epi8(0x80u);
5252
if ((_mm_testz_si128(_mm_or_si128(in.v0, in.v1), high_bit)) == 1) {
5353
// it is ascii, we just check continuation
5454
state.has_error =
@@ -140,10 +140,10 @@ really_inline void find_whitespace_and_structurals<Architecture::WESTMERE>(
140140
simd_input<Architecture::WESTMERE> in, uint64_t &whitespace,
141141
uint64_t &structurals) {
142142
const __m128i structural_table =
143-
_mm_setr_epi8(44, 125, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123);
143+
_mm_setr_epi8(44, 125, 0, 0, 0xc0u, 0, 0, 0, 0, 0, 0, 0, 0, 0, 58, 123);
144144
const __m128i white_table = _mm_setr_epi8(32, 100, 100, 100, 17, 100, 113, 2,
145145
100, 9, 10, 112, 100, 13, 100, 100);
146-
const __m128i struct_offset = _mm_set1_epi8(0xd4);
146+
const __m128i struct_offset = _mm_set1_epi8(0xd4u);
147147
const __m128i struct_mask = _mm_set1_epi8(32);
148148

149149
__m128i white0 = _mm_cmpeq_epi8(in.v0, _mm_shuffle_epi8(white_table, in.v0));

src/parsedjsoniterator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ParsedJson::Iterator::Iterator(ParsedJson &pj_)
3434

3535
ParsedJson::Iterator::~Iterator() { delete[] depth_index; }
3636

37-
ParsedJson::Iterator::Iterator(const Iterator &o)
37+
ParsedJson::Iterator::Iterator(const Iterator &o) noexcept
3838
: pj(o.pj), depth(o.depth), location(o.location), tape_length(0),
3939
current_type(o.current_type), current_val(o.current_val),
4040
depth_index(nullptr) {
@@ -45,7 +45,7 @@ ParsedJson::Iterator::Iterator(const Iterator &o)
4545
tape_length = o.tape_length;
4646
}
4747

48-
ParsedJson::Iterator::Iterator(Iterator &&o)
48+
ParsedJson::Iterator::Iterator(Iterator &&o) noexcept
4949
: pj(o.pj), depth(o.depth), location(o.location),
5050
tape_length(o.tape_length), current_type(o.current_type),
5151
current_val(o.current_val), depth_index(o.depth_index) {
@@ -114,7 +114,7 @@ bool ParsedJson::Iterator::move_to(const char *pointer, uint32_t length) {
114114
}
115115
new_pointer[new_length] = fragment;
116116
i += 3;
117-
} catch (std::invalid_argument &e) {
117+
} catch (std::invalid_argument &) {
118118
delete[] new_pointer;
119119
return false; // the fragment is invalid
120120
}

tests/jsoncheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool validate(const char *dirname) {
6868
simdjson::padded_string p;
6969
try {
7070
simdjson::get_corpus(fullpath).swap(p);
71-
} catch (const std::exception &e) {
71+
} catch (const std::exception &) {
7272
std::cerr << "Could not load the file " << fullpath << std::endl;
7373
return EXIT_FAILURE;
7474
}

0 commit comments

Comments
 (0)