<div dir="ltr"><div dir="ltr"><div>Hi all :)</div><div><br></div><div>I noticed that clang doesn't emit a warning in this case.</div><div>It does when calling a *pure* virtual function though (a warning for which I added a diagnostic group recently [1]).</div><div>I think one difference is that calling pure virtual function from constructor is undefined, while calling virtual function is defined (it calls the base class function since the vtable isn't filled yet with inherited virtual functions reimplementations).</div><div>So implementing a warning like this will likely trigger false positives.</div><div><br></div><div>However, I think in most cases it denotes a bug, since many IMHO C++ developers won't get that the function will not behave as they might expect.</div><div>Also, we can have a fixit to this, by suggesting the user to to specify the class of the function e.g. write "B::f()" instead of "f()".</div><div><br></div><div>I'm fine (trying to) write a patch for this, but first I wanted to get opinions about whether it's worth it.</div><div>I guess it might not be that much difficult to do for simple cases (when calling virtual function directly). I expect it might be more difficult to catch cases where we call a function that is not virtual, but which calls a virtual function behind the scene.<br></div><div>Also, if you're worried about having too many false positives, I think we could put this new warning behind Wextra.</div><div><br></div><div>What do you think?<br></div><div><br></div><div>Best regards,</div><div>Arnaud<br></div><div><br></div><div>[1]: <a href="https://github.com/llvm-mirror/clang/commit/528a1d17a3ff8361fdd4a1a379adf3f64ec68e00">https://github.com/llvm-mirror/clang/commit/528a1d17a3ff8361fdd4a1a379adf3f64ec68e00</a></div><div><br></div></div></div>