Skip to content

[C/C++] Generate uint64 max lengths and counts as unsigned literals - #1141

Open
slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-uint64-length-max-literal
Open

slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-uint64-length-max-literal

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

applicableMaxValue().longValue() holds the uint64 maximum as -2, so a schema with a uint64 numInGroup or var-data length generates range checks such as str.length() > -2 and count > -2LL. Those still work through the implicit conversion but fail -Wsign-compare. The checks now use UINT64_C(0xfffffffffffffffe); generated code for every other type is unchanged. uint64-length-schema.xml and a C and a C++ test cover the case.

Verified: generated headers for the new schema with -Wall -Wextra -Werror → master 5 sign-compare errors in C++ and 1 in C, none with this change; ctest 23/23 under ASan/UBSan.

applicableMaxValue() holds the uint64 max as a negative long, so the E109
and E110 range checks compared an unsigned length or count against -2 and
failed -Wsign-compare. They now use UINT64_C(0xfffffffffffffffe); the
generated code for every other type is unchanged.
@slachiewicz
slachiewicz marked this pull request as ready for review October 23, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant