Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Collect Stub Information does not add make_shared in Stubs view in Parasoft C/C++test 2021.1

Aneesh Posts: 1

I am trying to stub the make_shared which is an inline function, to get 100% decision coverage but the Collect Stub Information Test configuration is not adding it to the Stubs view.

Here is how I use it in ATM example of Parasoft

std::shared_ptr foo = std::make_shared (10);
if(foo == null)
// error statements (not covered in decision coverage)
// do something with foo (covered in decision coverage)

How to get this function in Stubs view or Is make_shared not supported by the stubs?
I have tried a similar example using an inline function in c program, that seems to work. i.e, Parasoft tool was able to add it to Stubs view.



  • ryanamunoz
    ryanamunoz Posts: 2

    Hello Aneesh,

    For this case, it seems your use of make_shared is related to a template.

    The current support for templates has certain limitations, and it is not possible to create stubs for templates or functions called from template method bodies.

    The subject is not easy and it is related to language and technical limitations not allowing C/C++test to get enough information to perform stubbing at the right moment.

    1. C/C++test cannot stub pure (uninstantiated) templates, because pure template definitions are not really read by parser until it sees actual use of the template for some type parameter.
    2. C/C++test cannot stub instantiated templates either, so even if C++ code uses some template instantiated for concrete type parameter, C/C++test still will not be able to call stubs from such instances.


    1. C/C++test can use stubs with templates when there is an explicit template specialization.
    2. C/C++test can stub regular functions that take template arguments with concrete type parameter, e.g. func(MyClass & obj).

    I know that further research is planned by C/C++test team to improve template stubbing support, but this is not likely to happen short-term due to complex nature of the topic.

    I am sorry I do not have better news.