Initialize variables to address warning regarding possible use of uninitialized variables
Which compiler is raising these warnings? What compiler version and what compilation flags?
The compiler I am using is gcc (Debian 14.2.0-3) 14.2.0. I am not using any special flags, I just run bazel build //....
Could you rebase? I suspect the failing tests were at head.
yeah, no problem
Rebased this again since it's been a bit; feel free to re-run tests and review whenever you find time!
I don't think this is the correct fix.
The real issue here is that both upb_WireReader_ReadTag() and upb_WireReader_ReadSize() can return NULL to indicate error, and in that case the variables will not be initialized.
However, in this case the data is coming from the unknown fields of a upb_Message. We should be guaranteed that this is valid wire format.
I would suggest the following fix. This should make the warnings go away:
Add UPB_ASSUME(ptr != NULL) after the upb_WireReader_ReadTag() and upb_WireReader_ReadSize() calls. As a bonus, this will give us loud warnings in debug mode if these assumptions turn out not to be true.
We should probably do the same for every WireReader call in this function that returns ptr.
It's possible that we may need to add UPB_ASSUME(ret != NULL) into the success paths of the WireReader functions also.
We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.
This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.
We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active or becomes active again, please reopen it.
This PR was closed and archived because there has been no new activity in the 14 days since the inactive label was added.