Consider the example below. When compiled with flag -O3 methods meth_used and meth_unused aren't present in the resulting assembly at all.
Now consider the situation when this class is a part of the package compiled into the shared library and both meth_used and meth_unused are API of this package. Without the symbols for meth_used and meth_unused it's pretty much assumed that the user will have c++ code that will recompile those function into the user code. It's impossible to bind from other languages only knowing symbols without c++ coding. gcc should have an option, either compiler option, or the special keyword on the method, that would guarantee the method presence in the object. I looked into __attribute__ visibility. It only allows these values: "default", "hidden", "protected" or "internal" and doesn't help in this situation. Maybe "public" visibility should be added for this case? -- example header: exp.h -- extern void zzz(); class Abc { public: void meth_used() { zzz(); } void meth_unused() { zzz(); } }; -- example header: exp.C -- #include "exp.h" void my_exp() { (new Abc)->meth_used(); } -- Summary: Need an option that will create symbols for all public c++ methods, not only for those which bodies are outside the class declaration Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: yuri at tsoft dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44285