diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-10-16 20:09:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-16 20:09:46 +0200 |
commit | 1e8d9f6c5fb6848bf9665a18a16f5e854f9ebcf8 (patch) | |
tree | 27537e2b06b275e8989b9358f1b52117a35117b7 | |
parent | d904efb1c5a26846462c6e960b72ae0f91af49fe (diff) | |
parent | 07b00c404f89a15210b0b3ece91bac75adc336d1 (diff) |
Merge pull request #28954 from vespa-engine/balder/avoid-gcc12plus-xxhash-incorrect-warning
Avoid incorrect gcc warning compiling inlined XXH3 code. Also stick t…
-rw-r--r-- | document/src/vespa/document/bucket/bucketid.cpp | 23 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/fuzzy/sparse_state.h | 2 |
2 files changed, 22 insertions, 3 deletions
diff --git a/document/src/vespa/document/bucket/bucketid.cpp b/document/src/vespa/document/bucket/bucketid.cpp index c077d2dd4f6..8422b34473c 100644 --- a/document/src/vespa/document/bucket/bucketid.cpp +++ b/document/src/vespa/document/bucket/bucketid.cpp @@ -8,7 +8,7 @@ #include <vespa/vespalib/stllike/hash_set.hpp> #include <vespa/vespalib/util/stringfmt.h> #include <limits> -#include <xxh3.h> +#include <xxhash.h> using vespalib::nbostream; using vespalib::asciistream; @@ -80,7 +80,26 @@ void BucketId::initialize() noexcept { uint64_t BucketId::hash::operator () (const BucketId& bucketId) const noexcept { const uint64_t raw_id = bucketId.getId(); - return XXH3_64bits(&raw_id, sizeof(uint64_t)); + /* + * This is a workaround for gcc 12 and on that produces incorrect warning + * /home/balder/git/vespa/document/src/vespa/document/bucket/bucketid.cpp: In member function ‘uint64_t document::BucketId::hash::operator()(const document::BucketId&) const’: + * /home/balder/git/vespa/document/src/vespa/document/bucket/bucketid.cpp:83:23: error: ‘raw_id’ may be used uninitialized [-Werror=maybe-uninitialized] + * 83 | return XXH3_64bits(&raw_id, sizeof(uint64_t)); + * | ^ + * In file included from /usr/include/xxh3.h:55, + * from /home/balder/git/vespa/document/src/vespa/document/bucket/bucketid.cpp:11: + * /usr/include/xxhash.h:5719:29: note: by argument 1 of type ‘const void*’ to ‘XXH64_hash_t XXH_INLINE_XXH3_64bits(const void*, size_t)’ declared here + * 5719 | XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(XXH_NOESCAPE const void* input, size_t length) + * | ^~~~~~~~~~~ + * /home/balder/git/vespa/document/src/vespa/document/bucket/bucketid.cpp:82:14: note: ‘raw_id’ declared here + * 82 | uint64_t raw_id = bucketId.getId(); + * | ^~~~~~ + * cc1plus: all warnings being treated as errors + */ + uint8_t raw_as_bytes[sizeof(raw_id)]; + memcpy(raw_as_bytes, &raw_id, sizeof(raw_id)); + + return XXH3_64bits(raw_as_bytes, sizeof(raw_as_bytes)); } vespalib::string diff --git a/vespalib/src/vespa/vespalib/fuzzy/sparse_state.h b/vespalib/src/vespa/vespalib/fuzzy/sparse_state.h index 0f58853170e..7e381468fbe 100644 --- a/vespalib/src/vespa/vespalib/fuzzy/sparse_state.h +++ b/vespalib/src/vespa/vespalib/fuzzy/sparse_state.h @@ -8,7 +8,7 @@ #include <cstdint> #include <ostream> #include <span> -#include <xxh3.h> // TODO factor out? +#include <xxhash.h> // TODO factor out? namespace vespalib::fuzzy { |