Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mshabunin
Copy link
Contributor

@mshabunin mshabunin commented Feb 6, 2023

Numerous warnings (mostly in tests) have been produced when compiling with clang 14. Most are about missing override.

Update: added opencv/opencv_contrib#3436 with more warnings fix

force_builders=Custom
build_image:Custom=ubuntu-clang:18.04
buildworker:Custom=linux-4,linux-4

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

#if defined(__OPENCV_BUILD) && defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#pragma clang diagnostic ignored "-Wdeprecated-copy"
Copy link
Member

Choose a reason for hiding this comment

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

Need to merge it with line 128.

There are 1400+ warnings for clang 6.0: http://pullrequest.opencv.org/buildbot/builders/precommit_custom_linux/builds/100200

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, there are only 11 warnings now: 10 in ADE (should be fixed by opencv/ade#33) and 1 in sample.

Copy link
Contributor Author

@mshabunin mshabunin Feb 6, 2023

Choose a reason for hiding this comment

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

I have not checked clang-6 though, will try it later. Checked with clang-6, it should be clean now.

#endif

#if defined(__OPENCV_BUILD) && defined(__clang__)
#pragma clang diagnostic push
Copy link
Member

Choose a reason for hiding this comment

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

Missing push/pop is here for a reason: to avoid massive patching of legacy tests with override.

$ grep -Rni prepare_to_validation ./modules/ | wc -l
135

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is strange, but it works for me, I don't get warnings related to prepare_to_validation missing override. I tried clang-6, clang-14, clang-17 and only warnings I can see are from ADE.

return cmp(pts_[idx1], pts_[idx2]);
}
private:
KeypointComparator& operator=(const KeypointComparator&) = delete;
Copy link
Member

Choose a reason for hiding this comment

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

Removal is not an option for = delete.
Usually it is a guard, because default compiler generated code is not correct and we should not use copying at all.

Try to declare deleted copy ctor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this specific case I thought that this class is only used in a single place to sort keypoints and nobody actually use operator= because it is also private. So I decided that probably this was just a habit of implementing safe class.

Maybe it would be better to rewrite sort like this? What do you think?

    comparators::KeypointGreater cmp;
    std::sort(idxs.data(), idxs.data() + desc.rows, 
        [&](int lhs, int rhs){ return cmp(pts[lhs], pts[rhs]); });

Copy link
Member

Choose a reason for hiding this comment

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

There is no labmda's on 3.4 branch (no C++11)

}
}

DepthFrameProcessor::~DepthFrameProcessor()
Copy link
Member

Choose a reason for hiding this comment

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

It is better to drop noexcept from the header file instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@opencv-pushbot opencv-pushbot merged commit 649841e into opencv:4.x Feb 8, 2023
@mshabunin mshabunin deleted the fix-clang-warnings branch February 8, 2023 18:45
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants