Bug 1369837: Add a void cast to silence clang Wcomma build warning, in sandbox's snapshot of chromium header. r?bobowen
The build warning is for "possible misuse of comma operator".
The comma operator is a bit of a footgun becasue its first operand's result
just gets dropped on the floor (in this case, the result of the DCHECK
expression). It appears that Chromium's use of the comma operator here is
intentional, though -- so we might as well accept clang's suggestion and "cast
expression to void to silence warning".
This is also filed upstream as:
https://bugs.chromium.org/p/chromium/issues/detail?id=729123
MozReview-Commit-ID: Al2xsYEo3p0
--- a/security/sandbox/chromium/base/time/time.h
+++ b/security/sandbox/chromium/base/time/time.h
@@ -682,17 +682,17 @@ constexpr TimeDelta TimeDelta::FromDoubl
// static
constexpr TimeDelta TimeDelta::FromProduct(int64_t value,
int64_t positive_value) {
return (
#if !defined(_PREFAST_) || !defined(OS_WIN)
// Avoid internal compiler errors in /analyze builds with VS 2015
// update 3.
// https://connect.microsoft.com/VisualStudio/feedback/details/2870865
- DCHECK(positive_value > 0),
+ static_cast<void>(DCHECK(positive_value > 0)),
#endif
value > std::numeric_limits<int64_t>::max() / positive_value
? Max()
: value < -std::numeric_limits<int64_t>::max() / positive_value
? -Max()
: TimeDelta(value * positive_value));
}