hhvm: avoid a GCC7 warning by adding positive int constraints
commit22c616bf5e6ee846b132426dff91836457ee182f
authorPádraig Brady <pbrady@fb.com>
Mon, 20 Nov 2017 22:26:26 +0000 (20 14:26 -0800)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Tue, 21 Nov 2017 16:56:37 +0000 (21 08:56 -0800)
treec98b6e130925ad0491375eca1cb4c74d974ba19c
parent02ba5dbb57089cdd81d67aeb8f38892a5e983ddb
hhvm: avoid a GCC7 warning by adding positive int constraints

Summary:
GCC 7 compile fails with:
  In member function 'void HPHP::ThriftBuffer::read(char*, int)',
    inlined from 'void HPHP::ThriftBuffer::read(int8_t&)'
      at hphp/runtime/base/thrift-buffer.h:129:11,
    inlined from 'void HPHP::ThriftBuffer::skip(int8_t)'
      at hphp/runtime/base/thrift-buffer.cpp:135:27:
  hphp/runtime/base/thrift-buffer.cpp:94:19: error:
    'void* memcpy(void*, const void*, size_t)':
    specified size between 18446744071562067968 and 18446744073709551615
    exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]

So for int8_t the compiler thinks that `int avail` at
hphp/runtime/base/thrift-buffer.cpp:83 may go negative.
There is no way that m_p can go beyond m_pEnd,
so use not_reached() to enforce only positive values for avail.

Reviewed By: markw65

Differential Revision: D6372117

fbshipit-source-id: 0b16e0a4b2a98c036174643f7bb83a08a7ab507d
hphp/runtime/base/thrift-buffer.cpp