flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’

Open psionic12 opened this issue 1 year ago • 2 comments

Version: 23.5.26

After this change, the type of "size" becames to signed, but the field in class Verifier still use size_t, which is unsigned in C++ standard.

So this will lead to this compilation failure:

In file included from /home/lleo/FlatBuffers/23.5.26/include/flatbuffers/base.h:20,
                 from /home/lleo/FlatBuffers/23.5.26/include/flatbuffers/array.h:23,
                 from /home/lleo/FlatBuffers/23.5.26/include/flatbuffers/flatbuffers.h:24,
               	 from /home/lleo/MyExample/main.cpp,
/home/lleo/FlatBuffers/23.5.26/include/flatbuffers/flexbuffers.h: In constructor ‘flexbuffers::Verifier::Verifier(const uint8_t*, size_t, std::vector<unsigned char>*, bool, size_t)’:
/home/lleo/FlatBuffers/23.5.26/include/flatbuffers/flexbuffers.h:1673:30: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
 1673 |     FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
/home/lleo/FlatBuffers/23.5.26/include/flatbuffers/flexbuffers.h:1673:5: note: in expansion of macro ‘FLATBUFFERS_ASSERT’
 1673 |     FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE);
      |     ^~~~~~~~~~~~~~~~~~

psionic12 avatar Jan 05 '24 09:01 psionic12

Has it been fixed yet?

ifdreams avatar Feb 01 '24 01:02 ifdreams

--FLATBUFFERS_ASSERT(size_ < FLATBUFFERS_MAX_BUFFER_SIZE); ++FLATBUFFERS_ASSERT(static_cast<::flatbuffers::soffset_t>(size_) < FLATBUFFERS_MAX_BUFFER_SIZE);

ifdreams avatar Feb 01 '24 01:02 ifdreams

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Aug 02 '24 20:08 github-actions[bot]

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.

github-actions[bot] avatar Aug 16 '24 20:08 github-actions[bot]