<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Type-dependent explicit destructor call behaves improperly"
   href="https://llvm.org/bugs/show_bug.cgi?id=28265">28265</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Type-dependent explicit destructor call behaves improperly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aaron@aaronballman.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>There are two likely-related bugs with explicit destructor calls for a
dependent type. The first bug is that the same diagnostic is trigger multiple
times when it should only be triggered once. The second bug is that the
diagnostic includes a fixit that should not be triggered for dependent types.

Given:

template<typename T>
struct TypeDependent {
 void Destruct(T *T1) {
  T1->~T(); // No fixit should be suggested because T is type dependent.
 }
};

template <typename T>
struct NotTypeDependent {
  void Destruct(struct Derived *P) {
    P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
  }
};

struct Base {
 virtual void f() = 0;
};

struct Derived : Base {
 virtual void f() override;
};

void f() {
  TypeDependent<Derived> BadProblem;
  NotTypeDependent<Derived> FineProblem;

  BadProblem.Destruct(nullptr);
  FineProblem.Destruct(nullptr);
}

E:\llvm\2015>clang -fsyntax-only -Wall -std=c++11 E:\Desktop\ForAaron2.cpp
E:\Desktop\ForAaron2.cpp:4:3: warning: destructor called on non-final 'Derived'
that has virtual functions but
      non-virtual destructor [-Wdelete-non-virtual-dtor]
  T1->~T(); // No fixit should be suggested because T is type dependent.
  ^
E:\Desktop\ForAaron2.cpp:27:14: note: in instantiation of member function
'TypeDependent<Derived>::Destruct' requested
      here
  BadProblem.Destruct(nullptr);
             ^
E:\Desktop\ForAaron2.cpp:4:8: note: qualify call to silence this warning
  T1->~T(); // No fixit should be suggested because T is type dependent.
       ^
       Derived::
E:\Desktop\ForAaron2.cpp:11:5: warning: destructor called on non-final
'Derived' that has virtual functions but
      non-virtual destructor [-Wdelete-non-virtual-dtor]
    P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
    ^
E:\Desktop\ForAaron2.cpp:11:8: note: qualify call to silence this warning
    P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
       ^
       Derived::
E:\Desktop\ForAaron2.cpp:11:5: warning: destructor called on non-final
'Derived' that has virtual functions but
      non-virtual destructor [-Wdelete-non-virtual-dtor]
    P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
    ^
E:\Desktop\ForAaron2.cpp:28:15: note: in instantiation of member function
'NotTypeDependent<Derived>::Destruct'
      requested here
  FineProblem.Destruct(nullptr);
              ^
E:\Desktop\ForAaron2.cpp:11:8: note: qualify call to silence this warning
    P->~Derived(); // It's fine to suggest a fixit because P isn't type
dependent.
       ^
       Derived::
3 warnings generated.

The dependent case should not recommend T->Derived::~T() as a fixit, and the
non-dependent case should not trigger two diagnostics for the same issue.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>