-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Labels
clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)false-positiveWarning fires when it should notWarning fires when it should not
Description
https://godbolt.org/z/cGxozPYWj
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
void foo() {
std::vector<std::string> v;
std::string_view view;
for (const auto& s : v) {
view = s; // warning: 's' does not live long enough.
}
(void)view; // note: later used here.
}
void bar(const std::string& s) {
std::string_view view;
{
const std::string& ref = s; // 's' does not live long enough.
view = ref;
}
(void)view; // later used here.
}
Metadata
Metadata
Assignees
Labels
clang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)false-positiveWarning fires when it should notWarning fires when it should not
Type
Projects
Status
No status