[llvm-bugs] [Bug 51967] New: gsl::Owner seems not to work on custom class

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 24 23:48:01 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51967

            Bug ID: 51967
           Summary: gsl::Owner seems not to work on custom class
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tiagomacarios at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Looking at https://reviews.llvm.org/D64448 I was expecting a warning on both
lines inside of fun(), but I only get the warning with unique_ptr. Is this a
bug or am I not understanding who this should be used?

https://godbolt.org/z/571sYxad3

#include <memory>

template <typename T>
struct [[gsl::Owner]] my_unique_ptr
{
    T* m_p;
    T* get() const { return m_p; };
};

std::unique_ptr<int> get_unique_ptr();
my_unique_ptr<int> get_my_unique_ptr();

void fun()
{
    int* p1 = get_my_unique_ptr().get(); // no -Wdangling-gsl
    int* p2 = get_unique_ptr().get(); // -Wdangling-gsl
}

-- 
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/20210925/e569f098/attachment.html>


More information about the llvm-bugs mailing list