Skip to content

Fix UB caused by uninitialized variable i#3

Open
7FM wants to merge 1 commit intogchamp20:masterfrom
7FM:master
Open

Fix UB caused by uninitialized variable i#3
7FM wants to merge 1 commit intogchamp20:masterfrom
7FM:master

Conversation

@7FM
Copy link
Copy Markdown

@7FM 7FM commented Jul 24, 2025

Example output of clang:

RTOSBench/tests/mq/mq_workload.c:61:9: warning: relational comparison result unused [-Wunused-comparison]
   61 |         for (i < 0 ; i < NB_WORKLOAD_TASK; i++)
      |              ~~^~~
RTOSBench/tests/mq/mq_workload.c:61:7: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
   61 |         for (i < 0 ; i < NB_WORKLOAD_TASK; i++)
      |              ^
RTOSBench/tests/mq/mq_workload.c:46:11: note: initialize the variable 'i' to silence this warning
   46 |         int32_t i;
      |                  ^
      |                   = 0
RTOSBench/tests/mq/mq_workload.c:123:3: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
  123 |                 i++;
      |                 ^
RTOSBench/tests/mq/mq_workload.c:116:11: note: initialize the variable 'i' to silence this warning
  116 |         int32_t i;
      |                  ^
      |                   = 0
4 warnings generated.

As a consequence, Clang removes the entire loop, and the tests have no workload tasks.

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