Skip to content

Conversation

firewave
Copy link
Collaborator

No description provided.

@@ -774,7 +774,7 @@ void CheckBufferOverrun::stringNotZeroTerminated()
continue;
if (Token::simpleMatch(args[1], "(") && Token::simpleMatch(args[1]->astOperand1(), ". c_str") && args[1]->astOperand1()->astOperand1()) {
const std::list<ValueFlow::Value>& contValues = args[1]->astOperand1()->astOperand1()->values();
auto it = std::find_if(contValues.cbegin(), contValues.cend(), [](const ValueFlow::Value& value) {
auto it = std::find_if(contValues.cbegin(), contValues.cend(), [](const ValueFlow::Value& value) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think we should be adding an explicit return type on lambdas when it can be deduced.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It helps to deduce issue if you accidentally change the result. I had had such a case where I returned a wrong variable but it was accepted since the result was implicitly casted later on. It also helps with readability in case of bigger lambdas.

There is also a long-standing shortcoming in Clang (no idea bout others) with auto-deduced types generating worse code (I do not have the ticket handy right now).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is also a long-standing shortcoming in Clang (no idea bout others) with auto-deduced types generating worse code (I do not have the ticket handy right now).

See
llvm/llvm-project#144323
llvm/llvm-project#38674

Copy link

@firewave firewave marked this pull request as draft August 20, 2025 12:46
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.

2 participants