Skip to content

[clang] No warning on dangling iterator of Set containers #118064

@usx95

Description

@usx95

All usages are dangling references below:

#include <set>
#include <unordered_set>
#include <vector>

void sets() {
    auto x = std::set<int>{}.find(1);
    auto y = std::set<int>{}.begin();
    auto z = std::set<int>{}.end();
}
void sets2() {
    auto x = std::unordered_set<int>{}.find(1);
    auto y = std::unordered_set<int>{}.begin();
    auto z = std::unordered_set<int>{}.end();
}

void vector() {
    auto y2 = std::vector<int>{}.begin(); // Only warning here. Good!
}

https://godbolt.org/z/Mb4vr31P4

We might be missing [[clang::lifetimebound]] on these methods.

cc: @hokein

Metadata

Metadata

Assignees

Labels

clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)regression

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions