[llvm-bugs] [Bug 47640] New: -Wdangling-gsl only warns on initialization and not on assignment
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Sep 24 20:22:09 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47640
Bug ID: 47640
Summary: -Wdangling-gsl only warns on initialization and not on
assignment
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: rtrieu at google.com
CC: gribozavr at gmail.com, llvm-bugs at lists.llvm.org,
m.gehre at gmx.de, neeilans at live.com,
richard-llvm at metafoo.co.uk, xazax.hun at gmail.com
-Wdangling-gsl is a warning that catches dangling pointers. This warning
catches a lot of lifetime bugs, but it only does so during initialization.
Similar code that causes a dangling pointer during assignments does not get a
warning.
#include <string>
#include <string_view>
#include <memory>
std::string get_string();
std::unique_ptr<int> get_int();
int main() {
std::string_view sv = get_string(); // Warning on initialization
sv = get_string(); // No warning on assignment
int *p = get_int().get(); // Warning on initialization
p = get_int().get(); // No warning on assignment
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200925/b6fe178d/attachment.html>
More information about the llvm-bugs
mailing list