[llvm-bugs] [Bug 28817] New: -Wunneeded-member-function for dtor of trivially destructible class with internal linkage

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 2 06:32:20 PDT 2016


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

            Bug ID: 28817
           Summary: -Wunneeded-member-function for dtor of trivially
                    destructible class with internal linkage
           Product: clang
           Version: 3.8
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bloerwald at googlemail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16862
  --> https://llvm.org/bugs/attachment.cgi?id=16862&action=edit
reproducing source as file

When defining a class with a trivial, defaulted dtor,
-Wunneeded-member-function is emitted even when explicitly calling the dtor. If
adding a non-trivially destructible member (e.g. std::string), the warning is
no longer emitted:

  #include <string> // for non-trival member

  namespace {
    struct F {
      ~F() = default;
  #ifdef MEMBER
      MEMBER x;
  #endif
    };
  }

  void f()
  {
    F{}.~F();
  }

$ clang++ -UMEMBER -Wunneeded-member-function -c tmp.cpp -o/dev/null
--std=c++11
tmp.cpp:5:7: warning: member function '~F' is not needed and will not be
      emitted [-Wunneeded-member-function]
      ~F() = default;
      ^
1 warning generated.
$ clang++ -DMEMBER=int -Wunneeded-member-function -c tmp.cpp -o/dev/null
--std=c++11
tmp.cpp:5:7: warning: member function '~F' is not needed and will not be
      emitted [-Wunneeded-member-function]
      ~F() = default;
      ^
1 warning generated.
$ clang++ -DMEMBER=std::string -Wunneeded-member-function -c tmp.cpp
-o/dev/null --std=c++11
$

-- 
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/20160802/6d397c00/attachment-0001.html>


More information about the llvm-bugs mailing list