Short answer
Short answer: this appears to be "unfixable" bug 6532605 (I see it referenced on numerous google searches but I cannot open the bug itself on https://support.oracle.com/rs?type=bug&id=6532605).
A workaround done by Qt developers is to put the method definition in a separate compilation unit (.cpp file).
Background
If you demangle the symbol name that CC is complaining about, you can see that it is compiling a const __type_0& argument as the first argument:
$ echo __1cNrunGenEntries4nDstdGvector4Cin0AJallocator4Ci_____6FrkTArk1_v_ | c++filt
void runGenEntries<std::vector<int> >(const __type_0&,const __type_0&)
$
With g++ 3.4.6 on the exact same Solaris 10 box, the symbols from block 1 demangle as:
runGenEntries<std, vector<int, std::allocator,<int>void> >(const GenEntryRuleDrivenType<int::value_type>::type(const GenEntryRuleDrivenType<int::value_type>&)&)
runGenEntries<std, vector<int, std::allocator,<int>void> >(const GenEntryRulesDrivenType<int::value_type>::type(const GenEntryRulesDrivenType<int::value_type>&)&)
Why Oracle cannot achieve the same thing is beyond me.
The Qt Workaround
The Qt code where this bug/workaround are referenced is here.
We can see there are two functions declared with a similar name:
Expression::Ptr DocFN::typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType);
Expression::Ptr IdFN::typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType);
And each is compiled in its own source (here and here) to work around the bug.
Unsupported solution: Change the mangling option in ccfe
From here, you can also compile with -Qoption ccfe -abiopt=mangle6
. With these flags the code compiles successfully and the symbols (demangled) are:
void runGenEntries<std::vector<int> >(const GenEntryRuleDrivenType<__type_0::value_type>::type&,const __type_0&)
void runGenEntries<std::vector<int> >(const GenEntryRulesDrivenType<__type_0::value_type>::type&,const __type_0&)
The problem is that this compilation option is not supported, as written by Steve Clamage:
Finally, the compiler has a hidden option to fix all known mangling bugs unconditionally. We don't publicize the option because
- It is unstable. Future patches or releases could change mangling if more bugs are found.
- You might need to recompile all of the C++ code, including 3rd-party libraries, using this option.
- If you create a library with this option, it might be incompatible with code compiled without the option.
- As with all hidden options, it is subject to change or removal without notice.
- We view this option as "use at your own risk".
If after all these caveats you still want to try the option, here it is:
-Qoption ccfe -abiopt=mangle6
Be sure to add it to every CC command, and recompile everything.
Fortunately, none of the C++ system libraries shipped with Solaris or Studio is affected by this bug or the hidden option, so you don't need to worry about different versions of those libraries.