[llvm-bugs] [Bug 25084] -Wunneeded-member-function incorrect for default constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 20 18:40:34 PDT 2019


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

David Stone <david at doublewise.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from David Stone <david at doublewise.net> ---
Sorry, I had incorrectly reduced this bug when I initially posted this. Here is
the correct test case:

#include <type_traits>

namespace {

struct default_constructible {
        default_constructible() = default;
        default_constructible(default_constructible const &) = delete;
        default_constructible(default_constructible &&) = delete;
};

} // namespace

static_assert(std::is_default_constructible_v<default_constructible>);




https://godbolt.org/z/kieneu



We need to explicitly default the default constructor because we delete another
special member function. The code does not compile without the `= default`
line. However, it is used only at compile time, and thus the function does not
need to be emitted for use at link-time, which is presumably why this warning
is being triggered.

-- 
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/20190321/7abd2149/attachment.html>


More information about the llvm-bugs mailing list