Skip to content

Conversation

@gnawme
Copy link
Contributor

@gnawme gnawme commented Dec 23, 2025

Migrate #6368, Part B including apps changes to manage the size of the PR.

Add 4 additional bugprone clang-tidy checks and applied fixes

  1. bugprone-assert-side-effect
  2. bugprone-dangling-handle
  3. bugprone-forward-declaration-namespace
  4. bugprone-inaccurate-erase

Summary

These checks improve code safety and correctness by:

  • Preventing subtle bugs from dangling references
  • Ensuring consistent namespace declarations
  • Fixing incorrect container erase patterns
  • Eliminating side effects in assertions

@gnawme gnawme force-pushed the norm.evangelista/add-further-bugprone-checks-part-b branch from 6e0167f to c26c4c6 Compare December 31, 2025 18:01
Copy link
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not have a look at all the files yet, but here are already some comments.

In the cases where you introduced a dynamic_cast, I think it would be a good idea to check if the result is a nullptr before dereferencing it.

(*label_image)[euclidean_label_index.indices[j]].r = 255;
(*label_image)[euclidean_label_index.indices[j]].g = 0;
(*label_image)[euclidean_label_index.indices[j]].b = 0;
for (int index : euclidean_label_index.indices) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int index : euclidean_label_index.indices) {
for (const auto& index : euclidean_label_index.indices) {

for (const auto& region_index : region_indices) {
if (region_index.indices.size() > 1000) {
for (std::size_t j = 0; j < region_index.indices.size(); j++) {
for (int index : region_index.indices) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int index : region_index.indices) {
for (const auto& index : region_index.indices) {

pcl::PointXYZ ground_pt((*cloud)[region_index.indices[j]].x,
(*cloud)[region_index.indices[j]].y,
(*cloud)[region_index.indices[j]].z);
for (int index : region_index.indices) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int index : region_index.indices) {
for (const auto& index : region_index.indices) {

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.

3 participants