While compiling QtCreator using Solaris Studio I have come across to an interesting issue with name mangling:
Class QmlDesigner::AbstractView contains method
ModelNode createModelNode(const QString&, int, int, const PropertyListType&, const PropertyListType&, const QString&, ModelNode::NodeSourceType);
It is exported from the implementation file abstractview.cpp and used in qmlstate.cpp file linked to the same library
nm -C applied to the resulting shared object gives:
[10448] | 1576144| 169|FUNC |GLOB |0 |11 |QmlDesigner::ModelNode QmlDesigner::AbstractView::createModelNode(const QString&,int,int,const QList<QPair<QString,QVariant> >&,const QList<QPair<QString,QVariant> >&,const QString&,QmlDesigner::ModelNode::NodeSourceType)
[__1cLQdDmlDesignerMAbstractViewPcreateModelNode6MrknHQdDString_iirknFQdDList4nFQdDPair4n0C_nIQdDVariant_____74n0AJModelNodeONodeSourceType__8_]
^ ^
[14294] | 0| 0|FUNC |GLOB |0 |UNDEF |QmlDesigner::ModelNode QmlDesigner::AbstractView::createModelNode(const QString&,int,int,const QList<QPair<QString,QVariant> >&,const QList<QPair<QString,QVariant> >&,const QString&,QmlDesigner::ModelNode::NodeSourceType)
[__1cLQdDmlDesignerMAbstractViewPcreateModelNode6MrknHQdDString_iirknFQdDList4nFQdDPair4n0C_nIQdDVariant_____rk54n0AJModelNodeONodeSourceType__9B_]
^^^ ^^
I have marked characters which are different (7 replaced with rk5 and 8 with 9B)
Demangled output shows the same prototype but manglings are different (11 coming from abstractview.cpp and UNDEF from qmlstate.cpp)
I guess if the function were mangled same in both cases the linker would resolve it and the resulting shared object would not have undefined symbols
Is there any document describing mangling rules of CC compiler? I have once read an article at Oracle sites about ABI stability which mentions publishing such a document but I cannot google it anywhere.
Where does the difference come from? is it a bug in mangler or demangler?
I think mangling should be a 1-to-1 function not allowing two different codings for same prototype. Maybe the demangler does not correctly decode the small difference in the symbols above which decoded properly would indicate what the compiler "thought" of the function in while exporting and using as extern
I have noticed the same difference in mangling for Sun Studio 12 (CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25)
Solaris Studio 12.2 (CC: Sun C++ 5.11 SunOS_sparc/i386 2010/08/13)
and Solaris Studio 12.3 (CC: Sun C++ 5.12 SunOS_i386 2011/11/16)