-
Notifications
You must be signed in to change notification settings - Fork 557
Open
Description
Description
When generating the C++ codec for UtxErrorDto (and other messages containing varData fields), the generated method computeEncodedLength() contains incorrect size calculations. Specifically, the generator emits:
encodedLength += m_identity.size() * sizeof(null);However, null is not a valid type and results in incorrect encoded length calculation. Replacing sizeof(null) with sizeof(char) fixes the issue.
Generated Code (Incorrect)
std::size_t computeEncodedLength() const
{
std::size_t encodedLength = 0;
encodedLength += UtxLoginCommand::sbeBlockLength();
encodedLength += UtxLoginCommand::identityHeaderLength();
encodedLength += m_identity.size() * sizeof(null);
encodedLength += UtxLoginCommand::credentialHeaderLength();
encodedLength += m_credential.size() * sizeof(null);
encodedLength += UtxLoginCommand::collectedDataHeaderLength();
encodedLength += m_collectedData.size() * sizeof(null);
return encodedLength;
}Corrected Code (Works as expected)
std::size_t computeEncodedLength() const
{
std::size_t encodedLength = 0;
encodedLength += UtxLoginCommand::sbeBlockLength();
encodedLength += UtxLoginCommand::identityHeaderLength();
encodedLength += m_identity.size() * sizeof(char);
encodedLength += UtxLoginCommand::credentialHeaderLength();
encodedLength += m_credential.size() * sizeof(char);
encodedLength += UtxLoginCommand::collectedDataHeaderLength();
encodedLength += m_collectedData.size() * sizeof(char);
return encodedLength;
}Expected Behavior
The generator should use:
sizeof(char)
for all varData fields, since they are encoded as byte arrays.
Actual Behavior
The generator outputs:
sizeof(null)
which is invalid and results in incorrect encoded length calculation.
Steps to Reproduce
Define a message containing <data type="varData">
Generate C++ codecs
Inspect the generated computeEncodedLength() method
Observe that sizeof(null) is emitted instead of sizeof(char)
Metadata
Metadata
Assignees
Labels
No labels