[cfe-dev] Warning about undefined methods/static attributes ?

Matthieu Monrocq matthieu.monrocq at gmail.com
Mon Aug 27 04:48:43 PDT 2012


Hello,

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.

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.

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).

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.

What are your thoughts ?

-- Matthieu.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120827/8fe48cee/attachment.html>


More information about the cfe-dev mailing list