<br><br><div class="gmail_quote">On Mon, Aug 27, 2012 at 4:38 PM, Joshua Cranmer <span dir="ltr"><<a href="mailto:pidgeot18@gmail.com" target="_blank">pidgeot18@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 8/27/2012 6:48 AM, Matthieu Monrocq wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I just had the case today (yet another time) of a newcomer to the C++ language getting caught by the rather ominous message, when launching his binary: "undefined symbol _ZN....." because he had forgotten to implement one of the methods of his class.<br>

<br>
I was wondering whether there would be interest in a warning catching this, and if indeed people had ideas about implementing such a warning. I believe there are specific linker flags designed to catch this a bit earlier on, but even a warning at linking stage is too lately produced for a "beautiful" diagnosis.<br>

<br>
My idea was that once the AST has been completely produced for a given translation unit, one could check the methods/static attributes defined in the *one* file passed to the compiler (probably ending in .cpp) and check that all the classes involved are now complete (in terms of definition).<br>

<br>
This is definitely a heuristic, and may not make sense as a default warning if some projects have the habit of splitting their class implementation into several files, but I have never encountered such a case in practice.<br>

</blockquote>
<br></div></div>
It also doesn't make sense if you want to not provide definitions of some methods (a poor man's = delete for people who need to support pre-C++11).<br>
<br>
On Linux at least, -Wl,-z,defs will cause the linker to complain if you omit a method.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Joshua Cranmer<br>
News submodule owner<br>
DXR coauthor</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br><br>In no particular order:<br><br>> implementations split across files:<br><br>I think that at one point there had been a proposal for a group of warnings dedicated to beginners, I would expect such a missing-definition warning to be part of this group and not be on by default.<br>
<br>More seasoned developers are generally well aware of the issue and can read through mangled symbols (at least the first few words, to get the namespace(s), class/method names) and otherwise know to use c++filt (or equivalent) to get a readable one.<br>
<br>> linker flags:<br><br>I am aware that the linker may check this, as I said. However the diagnosis is not particularly pretty (in general), notably it is not pointing to the declaration of the method and the output need be run through c++filt to demangle the symbol (in C++).<br>
<br>> poor's man delete:<br><br>Indeed, this is a concern. It's a widely used technic pre-C++11. Such methods are generally private, and most often than not only consist of the copy constructor and assignment operator (I have used it only a few times to "remove" other operations), so maybe blacklisting those two (when declared private) would be sufficient to bring the noise level down to a reasonable treshold ?<br>
<br>I had not thought about this latter point and indeed it seems to put the idea of the warning in jeopardy. If nobody express any interest in this or has any very good idea on this latter point, I'll forget about it ;)<br>
<br>-- Matthieu<br><br>