Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
fix for when we only have one message type #102
While this fixes it, it's not perfectly efficient.
If you have 16 message types, you are serializing a type value in the range [0,15], hence the -1.
The problem occurs when the number of message types is 1, then it subtracts and get zero.
The code as written is attempting to go, oh, there is only one message type, so don't serialize the message type as an integer, since serializing an int in range [0,0] is undefined.
Most likely, there is a bug in the code such that there is uninitialized data on read in one of the serialize functions, such that the message type is not defaulted to 0. This is my guess anyway.
Could you try fixing this in such a way that it remains efficient? eg. keeps the -1, but special cases the numMessageTypes = 1 case.
I had no issue with a test project with only one message type, without the fix in question, on both Windows and Linux.
Plus, I'm not sure if the pull request would fix anything. The only changes are on a bunch of asserts and the removal of
Can you please give more details about your issue or provide a test project?
And more importantly, can we revert the pull request? The changes make the behavior wrong IMO, since you're not supposed to make a 0 bits write, and even then, the code is now inconsistent (other asserts later down the line still check that bits is > 0)