warning: comparison of unsigned expression >= 0 is always true thrown while building for samus device |
||
Issue description
While building for samus device, I noticed this:
service_worker_provider_host.cc:890:19: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
if (feature >= 0 &&
Digging a big lead me to this recent review:
https://chromium-review.googlesource.com/c/chromium/src/+/648659/15/content/browser/service_worker/service_worker_provider_host.cc
Maybe revert and redo this change?
,
Oct 12 2017
sgtm, thanks for investigating mcnee@ !
,
Oct 13 2017
@menee, thanks a lot, your investigation is correct. How to do this? |static_assert(std::is_unsigned<std::remove_reference<decltype(feature)>::type>::value, "feature must be unsigned");|
,
Oct 13 2017
We finally decide to create a CL now to fix this warning.
,
Oct 13 2017
,
Oct 13 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4d47a13e3d98ef30d74ae3d4671d57c097b7124e commit 4d47a13e3d98ef30d74ae3d4671d57c097b7124e Author: xzhan96 <xiaofeng.zhang@intel.com> Date: Fri Oct 13 06:37:44 2017 [ServiceWorker] Fix the warning for comparison of unsigned expression The original comparison is for the case that used_features will become signed in the future. BUG= 774200 Change-Id: I9607d44bd2163f260223b23c4bddac0891a5152f Reviewed-on: https://chromium-review.googlesource.com/717696 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Cr-Commit-Position: refs/heads/master@{#508620} [modify] https://crrev.com/4d47a13e3d98ef30d74ae3d4671d57c097b7124e/content/browser/service_worker/service_worker_provider_host.cc
,
Oct 13 2017
Thanks. #3: The static_assert that I suggested would let you keep using auto for the type of |feature| and then it would cause a compiler error if |feature| ever became signed, so we would know to update the code to handle signed values. But declaring the type to be unsigned also works, since you're still comparing |feature| with |kNumberOfFeatures|.
,
Oct 24 2017
|
||
►
Sign in to add a comment |
||
Comment 1 by mcnee@chromium.org
, Oct 12 2017