fuchsia: Fix sign-compare warning in divsufsort
ALPHABET_SIZE, BUCKET_A_SIZE, and BUCKET_B_SIZE are defined in terms of UINT8_MAX which is unsigned (at least on Fuchsia) and fairly small ((UINT8_MAX+1)^2). saidx_t and saint_t are signed. [25568->415/26982 ~1000] CXX obj/courgette/divsufsort/divsufsort.o FAILED: obj/courgette/divsufsort/divsufsort.o /usr/local/google/home/scottmg/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/courgette/divsufsort/divsufsort.o.d -DV8_DEPRECATION_WARNINGS -DDCHECK_ALWAYS_ON=1 -DUSE_AURA=1 -DUSE_OZONE=1 -DNO_TCMALLOC -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -DFUCHSIA_SDK_VERSION=05a1d1f99b5b8b4b8edb3097564b0653ec0f52bd -DCR_CLANG_REVISION=\"344066-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS -DCR_LIBCXX_REVISION=344254 -DCR_LIBCXXABI_REVISION=344215 -D_LIBCPP_ENABLE_NODISCARD -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWTF_USE_DYNAMIC_ANNOTATIONS=1 -I../.. -Igen -I../../third_party/fuchsia-sdk/sdk/pkg/async/include -I../../third_party/fuchsia-sdk/sdk/pkg/fdio/include -I../../third_party/fuchsia-sdk/sdk/pkg/zx/include -fno-strict-aliasing --param=ssp-buffer-size=4 -fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -funwind-tables -fPIC -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -fcomplete-member-pointers --target=x86_64-fuchsia -fno-sanitize=safe-stack -m64 -march=x86-64 -Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-unneeded-internal-declaration -Wno-undefined-var-template -Wno-null-pointer-arithmetic -Wno-ignored-pragma-optimize -Wno-defaulted-function-deleted -O0 -fno-omit-frame-pointer -g2 -ggnu-pubnames -fvisibility=hidden -Xclang -load -Xclang ../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang enforce-in-thirdparty-webkit -Xclang -plugin-arg-find-bad-constructs -Xclang check-enum-max-value -Xclang -plugin-arg-find-bad-constructs -Xclang check-ipc -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wno-shorten-64-to-32 -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++14 -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include --sysroot=../../third_party/fuchsia-sdk/sdk/arch/x64/sysroot -fvisibility-inlines-hidden -c ../../courgette/third_party/divsufsort/divsufsort.cc -o obj/courgette/divsufsort/divsufsort.o ../../courgette/third_party/divsufsort/divsufsort.cc:60:16: error: comparison of integers of different signs: 'divsuf::saidx_t' (aka 'int') and 'unsigned int' [-Werror,-Wsign-compare] for(i = 0; i < BUCKET_A_SIZE; ++i) { bucket_A[i] = 0; } ~ ^ ~~~~~~~~~~~~~ ../../courgette/third_party/divsufsort/divsufsort.cc:61:16: error: comparison of integers of different signs: 'divsuf::saidx_t' (aka 'int') and 'unsigned int' [-Werror,-Wsign-compare] for(i = 0; i < BUCKET_B_SIZE; ++i) { bucket_B[i] = 0; } ~ ^ ~~~~~~~~~~~~~ ../../courgette/third_party/divsufsort/divsufsort.cc:87:32: error: comparison of integers of different signs: 'divsuf::saint_t' (aka 'int') and 'unsigned int' [-Werror,-Wsign-compare] for(c0 = 0, i = 0, j = 0; c0 < ALPHABET_SIZE; ++c0) { ~~ ^ ~~~~~~~~~~~~~ ../../courgette/third_party/divsufsort/divsufsort.cc:91:25: error: comparison of integers of different signs: 'divsuf::saint_t' (aka 'int') and 'unsigned int' [-Werror,-Wsign-compare] for(c1 = c0 + 1; c1 < ALPHABET_SIZE; ++c1) { ~~ ^ ~~~~~~~~~~~~~ 4 errors generated. Bug: 808287 Change-Id: I57c416b029803d56157152f73c71742e9ba61ab9 Reviewed-on: https://chromium-review.googlesource.com/c/1298232 Commit-Queue: Scott Graham <scottmg@chromium.org> Reviewed-by: Samuel Huang <huangs@chromium.org> Cr-Commit-Position: refs/heads/master@{#602817}
This commit is contained in:
courgette/third_party/divsufsort
@ -32,3 +32,4 @@ List of changes made to original code:
|
||||
- Added namespace divsuf.
|
||||
- Added divsufsort_with_empty().
|
||||
- Added unit tests.
|
||||
- Patch to avoid int/uint comparison warnings.
|
||||
|
@ -57,8 +57,8 @@ sort_typeBstar(const sauchar_t *T, saidx_it SA,
|
||||
saint_t c0, c1;
|
||||
|
||||
/* Initialize bucket arrays. */
|
||||
for(i = 0; i < BUCKET_A_SIZE; ++i) { bucket_A[i] = 0; }
|
||||
for(i = 0; i < BUCKET_B_SIZE; ++i) { bucket_B[i] = 0; }
|
||||
for(i = 0; i < static_cast<saidx_t>(BUCKET_A_SIZE); ++i) { bucket_A[i] = 0; }
|
||||
for(i = 0; i < static_cast<saidx_t>(BUCKET_B_SIZE); ++i) { bucket_B[i] = 0; }
|
||||
|
||||
/* Count the number of occurrences of the first one or two characters of each
|
||||
type A, B and B* suffix. Moreover, store the beginning position of all
|
||||
@ -84,11 +84,11 @@ note:
|
||||
*/
|
||||
|
||||
/* Calculate the index of start/end point of each bucket. */
|
||||
for(c0 = 0, i = 0, j = 0; c0 < ALPHABET_SIZE; ++c0) {
|
||||
for(c0 = 0, i = 0, j = 0; c0 < static_cast<saint_t>(ALPHABET_SIZE); ++c0) {
|
||||
t = i + BUCKET_A(c0);
|
||||
BUCKET_A(c0) = i + j; /* start point */
|
||||
i = t + BUCKET_B(c0, c0);
|
||||
for(c1 = c0 + 1; c1 < ALPHABET_SIZE; ++c1) {
|
||||
for(c1 = c0 + 1; c1 < static_cast<saint_t>(ALPHABET_SIZE); ++c1) {
|
||||
j += BUCKET_BSTAR(c0, c1);
|
||||
BUCKET_BSTAR(c0, c1) = j; /* end point */
|
||||
i += BUCKET_B(c0, c1);
|
||||
|
Reference in New Issue
Block a user