[cfe-dev] Link error in clang but not g++

Marc Glisse marc.glisse at inria.fr
Thu Sep 15 10:15:36 PDT 2011


On Wed, 14 Sep 2011, Eli Friedman wrote:

> On Wed, Sep 14, 2011 at 9:55 AM, Holger Brandsmeier
> <holger.brandsmeier at sam.math.ethz.ch> wrote:
>> Dear clang list,
>>
>> first thank you a lot for providing clang, clang is really so much
>> better for error messages (especially templates) than gcc!
>>
>> I build a shared library essentialy with the CMake part
>>
>> add_library(integration quadraturePy.cpp quadratureRulesPy.cpp)
>>
>> In the file `quadratureRulesPy.cpp` the constructor for the template
>> QuadratureRules<double, 0> is define. It is also part of the object
>> file:
>>
>>> nm -C CMakeFiles/integration.dir/quadratureRulesPy.cpp.o | grep "parfem::QuadratureRules<double, 0>::QuadratureRules"
>> 00000000 W parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)
>>
>> In the file `quadraturePy.cpp` this symbol is not defined, and thus
>> also not part of the object file:
>>
>>> nm -C CMakeFiles/integration.dir/quadraturePy.cpp.o | grep "parfem::QuadratureRules<double, 0>::QuadratureRules"
>>         U parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)
>>
>> In the final library both object files are combined and the symbol
>> appears twice:
>>
>>> nm -C libintegration.so | grep "parfem::QuadratureRules<double, 0>::QuadratureRules"
>>         U parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)
>> 000ad400 W parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)
>
> Something very strange is happening in your link step; if I'm reading
> this right, it should not be possible...

Have you tried without -C? Demangling is not an injective operation, and 
_ZN6parfem15QuadratureRulesIdLi0EEC1Ej, 
_ZN6parfem15QuadratureRulesIdLi0EEC2Ej, 
_ZN6parfem15QuadratureRulesIdLi0EEC3Ej all print the same 
parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)

Other interesting tests include testing with a recent gcc (default 
visibility changed, more privatization, etc) to make sure the bug doesn't 
also appear there.

-- 
Marc Glisse



More information about the cfe-dev mailing list