[llvm-bugs] [Bug 38143] New: defaulted destructor makes defaulted copy constructor non-constexpr

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 11 18:39:52 PDT 2018


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

            Bug ID: 38143
           Summary: defaulted destructor makes defaulted copy constructor
                    non-constexpr
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mclow.lists at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Consider this code:

class span {
public:
    using pointer                = const int *;

    constexpr span() : __data{nullptr} {}

    constexpr span           (const span&) noexcept = default;
    constexpr span& operator=(const span&) noexcept = default;
    ~span() noexcept = default;

    constexpr pointer data()    const noexcept { return __data; }

private:
    pointer __data;
};

When compiled with a recent clang [clang version 7.0.0 (trunk 336548)],
(-std=c++2a) it gives an error:
junk.cpp:8:5: error: defaulted definition of copy assignment operator is not
      constexpr
    constexpr span& operator=(const span&) noexcept = default;
    ^

However, if I switch the order of the two lines to:
    ~span() noexcept = default;
    constexpr span& operator=(const span&) noexcept = default;

then it compiles w/o error.

However, I believe that it should compile w/o error in *both* cases.

-- 
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/20180712/f61428fc/attachment.html>


More information about the llvm-bugs mailing list