cppcoreguidelines-pro-bounds-array-to-pointer-decay on RCLCPP_* macros
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 805
- Forks
- 564
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 27
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- binaries
- Version or commit hash:
- rolling
- DDS implementation:
- default
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
1. Enable cppcoreguidelines-pro-bounds-array-to-pointer-decay in clang-tidy
2. Run clang-tidy over anything that has a RCLCPP_* macro in it
Expected behavior
No clang-tidy warnings.
Actual behavior
error: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,-warnings-as-errors]
RCLCPP_WARN(logger_, "yay, clang-tidy warning!");
^
/opt/ros/rolling/include/rclcpp/logging.hpp:970:5: note: expanded from macro 'RCLCPP_WARN'
RCUTILS_LOG_WARN_NAMED( \
^
/opt/ros/rolling/include/rcutils/logging_macros.h:747:3: note: expanded from macro 'RCUTILS_LOG_WARN_NAMED'
RCUTILS_LOG_COND_NAMED( \
^
/opt/ros/rolling/include/rcutils/logging_macros.h:68:5: note: expanded from macro 'RCUTILS_LOG_COND_NAMED'
RCUTILS_LOGGING_AUTOINIT; \
^
/opt/ros/rolling/include/rcutils/logging.h:531:39: note: expanded from macro 'RCUTILS_LOGGING_AUTOINIT'
RCUTILS_SAFE_FWRITE_TO_STDERR(rcutils_get_error_string().str); \
^
Feature request
This might not be feasible but I was trying to use this clang-tidy config and it the logging macros create a ton of warnings, not just this one. It would be really nice if we could find some way to replace the macros in RCLCPP with functions. Many of the errors in clang-tidy are because these expand into code from the c libraries. Another example is there are some c-style casts in these macros.
---
Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the cppcoreguidelines-pro-bounds-array-to-pointer-decay warning with a RCLCPP_* macro, then trace the expansion through rclcpp/logging.hpp, rcutils/logging_macros.h, and rcutils/logging.h. Compare the macro expansions with the supplied clang-tidy configuration; done means the logging macros no longer produce these warnings when checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100