<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - -Woverloaded-virtual shouldn't warn for final functions"
   href="https://bugs.llvm.org/show_bug.cgi?id=36644">36644</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Woverloaded-virtual shouldn't warn for final functions
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>benni.buch@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>struct A{
    virtual void f(int){}
};

struct B: A{
    virtual void f(double){}

    void f(int v)final{
        f(static_cast< double >(v));
    }
};

struct C: B{
    virtual void f(char){}

    void f(double v)final{
        f(static_cast< char >(v));
    }
};


The intent of the warning is to catch errors where you intended to override a
virtual function but made an error in the function type. final virtual
functions can't be overridden, so it shouldn't warn about it, but:


$ clang++ -c -Woverloaded-virtual -c main.cpp
main.cpp:14:18: warning: 'C::f' hides overloaded virtual function
[-Woverloaded-virtual]
    virtual void f(char){}
                 ^
main.cpp:8:10: note: hidden overloaded virtual function 'B::f' declared here:
type mismatch at 1st parameter ('int' vs 'char')
    void f(int v)final{
         ^
1 warning generated.

$ clang++ --version
clang version 6.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a>
4a005620928c39874a0177ec97d84e636ab8dbfc) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a>
e9667680470d3c40c51ff887fd33c2a91a07d62f)                                       
Target: x86_64-unknown-linux-gnu                                                
Thread model: posix                                                             
InstalledDir: /home/bebuch/media/programme/llvm/bin


The intent in the structure above it to convert a parameter of a virtual
function to another type and call a new virtual function with same name but new
type which can be overridden in a derived class. final makes clear that the
original virtual functions should not be overridden in derived classes anymore.</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>