<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 - -Winconsistent-missing-override does not fire on overriding "virtual void bar() final""
href="https://bugs.llvm.org/show_bug.cgi?id=36596">36596</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-Winconsistent-missing-override does not fire on overriding "virtual void bar() final"
</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>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>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>arthur.j.odwyer@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Note: This bug is similar to
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED INVALID - clang-tidy modernize-use-override: "final override": override is redundant. It's not."
href="show_bug.cgi?id=32079">https://bugs.llvm.org/show_bug.cgi?id=32079</a>
except that I am adding the "virtual" keyword to Roman's example in order to
deflect Alexander's objection. This bug is also similar to
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Warn if a method is virtual final but does not override anything."
href="show_bug.cgi?id=21051">https://bugs.llvm.org/show_bug.cgi?id=21051</a>
In fact I believe that fixing this bug could enable you to close 21051 as
no-longer-interesting.
Test case:
struct S {
virtual void foo();
virtual void bar();
};
struct T : public S {
VIRTUAL void foo() override;
VIRTUAL void NAME() final;
};
Compile with `-DVIRTUAL= -DNAME=bar`. This is the "best practice, no bug" case,
and naturally it gives no diagnostic.
Compile with `-DVIRTUAL= -DNAME=baz`. This is the "best practice, buggy" case.
Clang correctly diagnoses: "only virtual member functions can be marked
'final'."
Compile with `-DVIRTUAL=virtual -DNAME=baz`. This is the "bad practice, buggy"
case. Clang does not give any diagnostic, because the code seems to have a
reasonable interpretation.
Compile with `-DVIRTUAL=virtual -DNAME=bar`. This is the "bad practice, no bug"
case. Clang does not give any diagnostic.
In this fourth and last scenario, I would prefer Clang to give the diagnostic
"'bar' overrides a member function but is not marked 'override'
[-Winconsistent-missing-override]", because of the danger presented by typoing
the name of this function (replacing "bar" with "baz" silently changes the
meaning of the program).</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>