BIND 10 #1883: define tp_hash for some basic isc.dns classes

BIND 10 Development do-not-reply at isc.org
Fri Jul 6 14:36:26 UTC 2012


#1883: define tp_hash for some basic isc.dns classes
-------------------------------------+-------------------------------------
                   Reporter:         |                 Owner:  jinmei
  jinmei                             |                Status:  reviewing
                       Type:  task   |             Milestone:
                   Priority:  high   |  Sprint-20120717
                  Component:         |            Resolution:
  libdns++                           |             Sensitive:  0
                   Keywords:         |           Sub-Project:  DNS
            Defect Severity:  N/A    |  Estimated Difficulty:  5
Feature Depending on Ticket:         |           Total Hours:  0
        Add Hours to Ticket:  0      |
                  Internal?:  0      |
-------------------------------------+-------------------------------------
Changes (by jelte):

 * owner:  jelte => jinmei


Comment:

 Replying to [comment:6 jinmei]:
 > Replying to [comment:5 jelte]:
 >
 > So I introduced a wrapper converter and used it for all existing
 > cases.
 >

 My compiler (gcc 4.6) is being a PITA and fails on that code;

 (note, Shane reports success with gcc 4.7, and muks failure, also with
 4.6, so there's a good chance this is a version-specific compiler bug;
 however, it is a version that is present on a number of systems)

 {{{
 pydnspp_common.h: In function 'Py_hash_t
 isc::dns::python::convertToPyHash(HashvalType) [with HashvalType = long
 unsigned int, Py_hash_t = long int]':
 name_python.cc:527:60:   instantiated from here
 pydnspp_common.h:90:59: error: left shift count >= width of type [-Werror]
 cc1plus: all warnings being treated as errors
 }}}

 So it is able to figure out at compile time that a 64-bit left-shift
 (size_t) is no good, but it is not able to figure out that said statement
 wouldn't be reached for that type...

 So far the only workaround I've come up with is to replace it by a
 variable;
 {{{
         size_t mask_shift = (CHAR_BIT * sizeof(HashvalType));
         const Py_hash_t mask = ~(static_cast<Py_hash_t>(-1) <<
 mask_shift);
 }}}
 (note that it's not const; otherwise it would once again calculate it and
 trip over the value)

 The inverse case (else branch with uint16_t type) is also a problem;

 {{{
 In file included from rrclass_python.cc:23:0:
 pydnspp_common.h: In function 'Py_hash_t
 isc::dns::python::convertToPyHash(HashvalType) [with HashvalType = short
 unsigned int, Py_hash_t = long int]':
 rrclass_python.cc:271:62:   instantiated from here
 pydnspp_common.h:96:65: error: large integer implicitly truncated to
 unsigned type [-Werror=overflow]
 }}}

 another cast of the ~ output seems to shut it up here.

 But both these 'solutions' are quite ugly...

-- 
Ticket URL: <http://bind10.isc.org/ticket/1883#comment:8>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development


More information about the bind10-tickets mailing list