Does const remove ABI from function return type break?

Suppose I have a library that declares a function that returns a type of const :

 class Foo { ... }; const Foo makeFoo(); 

Now I want to remove const from makeFoo() of the return type (see my previous question ). I can remove const from both the header and cpp file, rebuild the library, and link my code to the new library. However, I also have old code dynamically linked to this library, and I want it to continue to work with the new version of the library.

So the first question is, does const remove the return break ABI from the type?

Second question: the actual code is completely different: this is a template class that has a static member function and which is subsequently explicitly created:

 // fooMaker.h template<class Foo> class FooMaker { public: static const Foo make(); }; // fooMaker.cpp template<class Foo> const Foo FooMaker<Foo>::make() { ... } template class FooMaker<Foo1>; template class FooMaker<Foo2>; 

Has anything changed?

If this is important, I use g ++ under linux.

+8
c ++ abi const
source share
1 answer

The following recommendations about what affects ABI show that the answer is yes, it violates compatibility with ABI:

You can not

...

For existing functions of any type:

  • change return type in any way

Since you are changing the return type from const Foo to Foo , I would say that this does not match the background.

+1
source share

All Articles