0

I've got this little code:

#include <iostream>

class Test {
  private:
    int i_;

 public:
    Test() :
      i_() {}

    Test(int i) :
      i_(i) {}

    ~Test() {}

    void dump() const {
      std::cout << "i " << i_ << std::endl;
    }
};

int main() {
  Test t(3);
  Test t1(t);
  Test t2(5);

  t2 = t;

  t.dump();
  t1.dump();
  t2.dump();

  return 0;
}

I know that C++ will, by itself, constructs a copy constructor and an affectation operator. That's why I can compile this code, even with flags and run it without any problems.

My question is:

  • Why with a nm -C <generated file> I can't see thoses members functions

-

$> g++ -W -Wall -Werror test.cpp
$> nm -C a.out
[...]
                 U _Unwind_Resume@@GCC_3.0
0000000000400a55 t __static_initialization_and_destruction_0(int, int)
0000000000400aa8 W Test::Test(int, int)
0000000000400aa8 W Test::Test(int, int)
0000000000400acc W Test::~Test()
0000000000400acc W Test::~Test()
0000000000400ad6 W Test::dump() const
[...]
$>
tbennett
  • 424
  • 1
  • 6
  • 18
  • I know their mangled names are not the same. but why `C++` need to do this? – tbennett Dec 04 '14 at 16:03
  • Both entries point to the same piece of code, I guess [the mangling scheme changed at some point](http://www.tldp.org/HOWTO/C++-dlopen/theproblem.html), and to retain compatibility, they have to include both the old and the new scheme for each entry. – didierc Dec 04 '14 at 16:17
  • "I can't see thoses members functions" they are inlined and need no symbols. – n. m. could be an AI Dec 06 '14 at 21:48

0 Answers0