views:

238

answers:

1

I am using Intel code coverage tools on Linux using g++ compiler. For a particular class, the coverage tool shows 2/3 extra functions than those actually present in source code.

What are these extra functions? Are they compiler generated functions?

I am excluding header files from code coverage. My classes are simple with empty ctor and dtor.

I guess following functions are generated by compiler.

  1. Copy Constructor
  2. Assignment operator
  3. Macro (Not in my case)
  4. Signal slot connection mechanisms (e.g. in Qt moc compiler generates these)
+1  A: 

This blog entry (concerned with debugging with GDB) explains why you see the "extra" Constructors.

gcc generates two distinct function bodies for a constructor. One is a regular one that constructs the entire object, including all bases. Another one constructs everything except for virtual base classes. As it happens, gcc emits both constructors even for classes that have no virtual bases at all.

lothar