thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbapple-cloudera <...@git.apache.org>
Subject [GitHub] thrift pull request #1214: THRIFT-2026: Eliminate some undefined behavior in...
Date Sun, 19 Mar 2017 02:06:56 GMT
Github user jbapple-cloudera commented on a diff in the pull request:

    https://github.com/apache/thrift/pull/1214#discussion_r106796209
  
    --- Diff: lib/cpp/src/thrift/protocol/TCompactProtocol.tcc ---
    @@ -387,7 +389,11 @@ uint32_t TCompactProtocolT<Transport_>::writeVarint64(uint64_t
n) {
      */
     template <class Transport_>
     uint64_t TCompactProtocolT<Transport_>::i64ToZigzag(const int64_t l) {
    -  return (l << 1) ^ (l >> 63);
    +  const int64_t m = l >> 63;
    +  uint64_t p, q;
    +  memcpy(&p, &l, sizeof(p));
    +  memcpy(&q, &m, sizeof(q));
    +  return p = (p << 1) ^ q;
    --- End diff --
    
    Good point.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message