BIND 10 trac1883, updated. 400da17fc216ce60be368e20dabdca638c81b45d [1883] workaround a build failure with g++ 4.6 using a mutable variable.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jul 6 18:08:27 UTC 2012
The branch, trac1883 has been updated
via 400da17fc216ce60be368e20dabdca638c81b45d (commit)
from d4ba721af6702333ee6f6130f0f0fe2efc3ff859 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 400da17fc216ce60be368e20dabdca638c81b45d
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Fri Jul 6 11:07:32 2012 -0700
[1883] workaround a build failure with g++ 4.6 using a mutable variable.
see the comment in the diff for the rationale.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/python/pydnspp_common.h | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/python/pydnspp_common.h b/src/lib/dns/python/pydnspp_common.h
index 1513dd9..3cc69c4 100644
--- a/src/lib/dns/python/pydnspp_common.h
+++ b/src/lib/dns/python/pydnspp_common.h
@@ -84,17 +84,22 @@ Py_hash_t
convertToPyHash(HashvalType val) {
BOOST_STATIC_ASSERT(sizeof(HashvalType) <= sizeof(Py_hash_t));
+ // Some versions of g++ doesn't ignore the impossible case of if/else
+ // below (depending on the size of HashvalType) and triggers a false
+ // warning.
+ // To work around it we use an intermediate mutable variable.
+ // See Trac #1883 for details.
+ size_t hash_val_bits = CHAR_BIT * sizeof(HashvalType);
+
if (sizeof(HashvalType) < sizeof(Py_hash_t)) {
- // The original hash type has small enough. Do trivial conversion.
- const Py_hash_t mask = ~(static_cast<Py_hash_t>(-1) <<
- (CHAR_BIT * sizeof(HashvalType)));
+ // The original hash type is small enough. Do trivial conversion.
+ const Py_hash_t mask = ~(static_cast<Py_hash_t>(-1) << hash_val_bits);
return (static_cast<Py_hash_t>(val) & mask);
} else {
// Clear the highest bit of the original hash so the conversion is
// safe and avoids -1.
- const HashvalType mask = ~(static_cast<HashvalType>(1) <<
- (CHAR_BIT * sizeof(HashvalType) - 1));
- BOOST_STATIC_ASSERT(mask != static_cast<HashvalType>(-1));
+ HashvalType mask = ~(static_cast<HashvalType>(1) <<
+ (hash_val_bits - 1));
return (val & mask);
}
}
More information about the bind10-changes
mailing list