Skip to content

-Wreturn-stack-address false positive #127195

Closed
@hokein

Description

@hokein

https://godbolt.org/z/YW8eeWG1x

namespace std {
template <typename T>
struct basic_string_view {
  const T* data() const;
};
using string_view = basic_string_view<char>;
}  // namespace std

template <typename T>
struct StatusOr {
  T* operator->() [[clang::lifetimebound]];
};

const char* s() {
  StatusOr<std::string_view> s;

  return s->data(); // bogus -Wreturn-stack-adddress diagnostic.
}

Metadata

Metadata

Assignees

Labels

clang:memory-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)false-positiveWarning fires when it should not

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions