Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc 10.x compile warning/error for array subscript 0 is outside the bounds in tests/bluetooth/tester/src/gap.c #28375

Closed
galak opened this issue Sep 14, 2020 · 0 comments · Fixed by #28476
Assignees
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@galak
Copy link
Collaborator

galak commented Sep 14, 2020

When building tests/bluetooth/tester on qemu_x86 with gcc 10.2 we get:

/home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c: In function 'tester_handle_gap':
/home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c:278:35: error: array subscript 254 is outside the bounds of an interior zero-length array 'const uint8_t[0]' {aka 'const unsigned char[]'} [-Werror=zero-length-bounds]
  278 |   ad[adv_len].type = cmd->adv_data[i++];
      |                      ~~~~~~~~~~~~~^~~~~
In file included from /home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c:25:
/home/galak/git/zephyr/tests/bluetooth/tester/src/bttester.h:157:10: note: while referencing 'adv_data'
  157 |  uint8_t adv_data[0];
      |          ^~~~~~~~
/home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c:279:39: error: array subscript 255 is outside the bounds of an interior zero-length array 'const uint8_t[0]' {aka 'const unsigned char[]'} [-Werror=zero-length-bounds]
  279 |   ad[adv_len].data_len = cmd->adv_data[i++];
      |                          ~~~~~~~~~~~~~^~~~~
In file included from /home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c:25:
/home/galak/git/zephyr/tests/bluetooth/tester/src/bttester.h:157:10: note: while referencing 'adv_data'
  157 |  uint8_t adv_data[0];
      |          ^~~~~~~~
/home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c:280:22: error: array subscript 256 is outside the bounds of an interior zero-length array 'const uint8_t[0]' {aka 'const unsigned char[]'} [-Werror=zero-length-bounds]
  280 |   ad[adv_len].data = &cmd->adv_data[i];
      |                      ^~~~~~~~~~~~~~~~~
In file included from /home/galak/git/zephyr/tests/bluetooth/tester/src/gap.c:25:
/home/galak/git/zephyr/tests/bluetooth/tester/src/bttester.h:157:10: note: while referencing 'adv_data'
  157 |  uint8_t adv_data[0];
      |          ^~~~~~~~
cc1: all warnings being treated as errors
@galak galak added bug The issue is a bug, or the PR is fixing a bug area: Bluetooth labels Sep 14, 2020
@galak galak added the priority: low Low impact/importance bug label Sep 15, 2020
carlescufi added a commit to carlescufi/zephyr that referenced this issue Sep 17, 2020
Fix the structures so that they are compliant with the stricter checks
of GCC 10.x, and at the same time correct a bug that was present in the
handling of the GAP Start Advertising BTP command.

Fixes zephyrproject-rtos#28375.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
carlescufi added a commit that referenced this issue Sep 18, 2020
Fix the structures so that they are compliant with the stricter checks
of GCC 10.x, and at the same time correct a bug that was present in the
handling of the GAP Start Advertising BTP command.

Fixes #28375.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants