Skip to content

Commit f42c880

Browse files
committed
* enable warning in GCC because PVS-Studio are also detect this. This is an error!
1 parent 0838651 commit f42c880

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

include/fast_float/ascii_number.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ read8_to_u64(UC const *chars) {
7171
#ifdef FASTFLOAT_SSE2
7272

7373
fastfloat_really_inline uint64_t simd_read8_to_u64(__m128i const &data) {
74-
FASTFLOAT_SIMD_DISABLE_WARNINGS
7574
// _mm_packus_epi16 is SSE2+, converts 8×u16 → 8×u8
7675
__m128i const packed = _mm_packus_epi16(data, data);
7776
#ifdef FASTFLOAT_64BIT
@@ -82,30 +81,23 @@ fastfloat_really_inline uint64_t simd_read8_to_u64(__m128i const &data) {
8281
_mm_storel_epi64(reinterpret_cast<__m128i *>(&value), packed);
8382
return value;
8483
#endif
85-
FASTFLOAT_SIMD_RESTORE_WARNINGS
8684
}
8785

8886
fastfloat_really_inline uint64_t simd_read8_to_u64(char16_t const *chars) {
89-
FASTFLOAT_SIMD_DISABLE_WARNINGS
9087
return simd_read8_to_u64(
91-
_mm_loadu_si128(reinterpret_cast<__m128i const *>(chars)));
92-
FASTFLOAT_SIMD_RESTORE_WARNINGS
88+
_mm_loadu_si128(reinterpret_cast<__m128i const *>(chars))); //TODO: V1032 https://pvs-studio.com/en/docs/warnings/v1032/ The pointer 'chars' is cast to a more strictly aligned pointer type.
9389
}
9490

9591
#elif defined(FASTFLOAT_NEON)
9692

9793
fastfloat_really_inline uint64_t simd_read8_to_u64(uint16x8_t const &data) {
98-
FASTFLOAT_SIMD_DISABLE_WARNINGS
9994
uint8x8_t utf8_packed = vmovn_u16(data);
10095
return vget_lane_u64(vreinterpret_u64_u8(utf8_packed), 0);
101-
FASTFLOAT_SIMD_RESTORE_WARNINGS
10296
}
10397

10498
fastfloat_really_inline uint64_t simd_read8_to_u64(char16_t const *chars) {
105-
FASTFLOAT_SIMD_DISABLE_WARNINGS
10699
return simd_read8_to_u64(
107100
vld1q_u16(reinterpret_cast<uint16_t const *>(chars)));
108-
FASTFLOAT_SIMD_RESTORE_WARNINGS
109101
}
110102

111103
#endif
@@ -162,10 +154,9 @@ simd_parse_if_eight_digits_unrolled(char16_t const *chars,
162154
return false;
163155
}
164156
#ifdef FASTFLOAT_SSE2
165-
FASTFLOAT_SIMD_DISABLE_WARNINGS
166157
// Load 8 UTF-16 characters (16 bytes)
167158
__m128i const data =
168-
_mm_loadu_si128(reinterpret_cast<__m128i const *>(chars));
159+
_mm_loadu_si128(reinterpret_cast<__m128i const *>(chars)); //TODO: V1032 https://pvs-studio.com/en/docs/warnings/v1032/ The pointer 'chars' is cast to a more strictly aligned pointer type.
169160

170161
// Branchless "are all digits?" trick from Lemire:
171162
// (x - '0') <= 9 <=> (x + 32720) <= 32729
@@ -179,9 +170,7 @@ simd_parse_if_eight_digits_unrolled(char16_t const *chars,
179170
i = i * 100000000 + parse_eight_digits_unrolled(simd_read8_to_u64(data));
180171
return true;
181172
}
182-
FASTFLOAT_SIMD_RESTORE_WARNINGS
183173
#elif defined(FASTFLOAT_NEON)
184-
FASTFLOAT_SIMD_DISABLE_WARNINGS
185174
uint16x8_t const data = vld1q_u16(reinterpret_cast<uint16_t const *>(chars));
186175

187176
// (x - '0') <= 9
@@ -193,7 +182,6 @@ simd_parse_if_eight_digits_unrolled(char16_t const *chars,
193182
i = i * 100000000 + parse_eight_digits_unrolled(simd_read8_to_u64(data));
194183
return true;
195184
}
196-
FASTFLOAT_SIMD_RESTORE_WARNINGS
197185
#else
198186
(void)chars;
199187
(void)i;

include/fast_float/float_common.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,20 @@ FASTFLOAT_CONSTEXPR20 To bit_cast(const From &from) {
205205
#define FASTFLOAT_HAS_SIMD 1
206206
#endif
207207

208+
// Don't silent this. This is an important warning!
208209
//#if defined(__GNUC__)
209210
// disable -Wcast-align=strict (GCC only)
210211
//#define FASTFLOAT_SIMD_DISABLE_WARNINGS \
211212
// _Pragma("GCC diagnostic push") \
212213
// _Pragma("GCC diagnostic ignored \"-Wcast-align\"")
213214
//#else
214-
#define FASTFLOAT_SIMD_DISABLE_WARNINGS
215+
//#define FASTFLOAT_SIMD_DISABLE_WARNINGS
215216
//#endif
216217

217218
//#if defined(__GNUC__)
218219
//#define FASTFLOAT_SIMD_RESTORE_WARNINGS _Pragma("GCC diagnostic pop")
219220
//#else
220-
#define FASTFLOAT_SIMD_RESTORE_WARNINGS
221+
//#define FASTFLOAT_SIMD_RESTORE_WARNINGS
221222
//#endif
222223

223224
#ifdef FASTFLOAT_VISUAL_STUDIO
@@ -336,8 +337,18 @@ template <typename T> struct span {
336337
};
337338

338339
struct value128 {
339-
uint64_t low;
340-
uint64_t high;
340+
union {
341+
struct {
342+
uint64_t low;
343+
uint64_t high;
344+
};
345+
#ifdef FASTFLOAT_SSE2
346+
__m128i full; // trick for test only
347+
#endif
348+
#ifdef FASTFLOAT_NEON
349+
uint16x8_t full; // trick for test only
350+
#endif
351+
};
341352

342353
constexpr value128(uint64_t _low, uint64_t _high) noexcept
343354
: low(_low), high(_high) {}

0 commit comments

Comments
 (0)