Skip to content

False positive -Wreturn-stack-address warning with optional #43348

@rogerorr

Description

@rogerorr
mannequin
Bugzilla Link 44003
Resolution FIXED
Resolved on Feb 19, 2020 06:30
Version trunk
OS Windows NT
CC @dwblaikie,@DougGregor,@zygoloid

Extended Description

The following code, with clang trunk and -std=c++17, produces a warning that I believe to be a false positive.

---- code ----
#include
#include <string_view>

std::string_view foo()
{
std::optionalstd::string_view sv("abc");
return *sv; // unwanted [-Wreturn-stack-address] warning
}
---- code ----

See https://godbolt.org/z/vTs3Kk

This is a regression since clang 9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions