zserio
zserio copied to clipboard
Signed comparison between literal and field in C++
Consider the following schema:
struct Test
{
varint32 id : id <= 268435454;
};
The C++ generates the construct get(Id) <= 268435454UL
which fires the C++ warning comparison between signed and unsigned integer expressions [-Wsign-compare]
.
The generator should not use unsigned literals in signed comparison because if one operator is unsigned in C++, all other operators are cast to unsigned:
(-1 > 1) => false
(-1 > 1U) => true