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

Holger Brandsmeier holger.brandsmeier at sam.math.ethz.ch
Wed Sep 14 15:33:53 PDT 2011


Eli,

it did not really matter much, how the constructor looks like. So I
was able to shorten it very much and still keep the error, namely:

  template<class ScalarT, int type>
  QuadratureRules<ScalarT, type>::QuadratureRules(unsigned int n)
  {
    bool cond = (n >= 2);
    if (!(cond)) {
      std::stringstream errorMsg;
      errorMsg << "by violating condition <n >= 2>";
      throw std::logic_error(errorMsg.str());
    }
  }

I can not shorten it much more, as otherwise the constructor is
removed from the object file completely (I guess due to optimization).
This is probably also bad by itself (the other file still references
the optimized-out constructor!), but my current goal is to simplify
the code as much as possible and still keep the error.

> nm -C libintegration.so | grep "parfem::QuadratureRules<double, 0>::QuadratureRules"
         U parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)
0007b7b0 W parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)

I also notice that the error disappears if I turn of optimization. So
the error is there if I use
`clang -ferror-limit=2 -g -O2` [...]
and also for -O3. Without any optimization the result is

> nm -C libintegration.so | grep "parfem::QuadratureRules<double, 0>::QuadratureRules"
000d3ac0 W parfem::QuadratureRules<double,
0>::QuadratureRules(parfem::QuadratureRules<double, 0> const&)
000d2a70 W parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)
000d3b30 W parfem::QuadratureRules<double,
0>::QuadratureRules(parfem::QuadratureRules<double, 0> const&)
000d2e10 W parfem::QuadratureRules<double, 0>::QuadratureRules(unsigned int)

-Holger

On Wed, Sep 14, 2011 at 23:46, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Wed, Sep 14, 2011 at 2:41 PM, Holger Brandsmeier
> <holger.brandsmeier at sam.math.ethz.ch> wrote:
>> On Wed, Sep 14, 2011 at 21:19, Eli Friedman <eli.friedman at gmail.com> wrote:
>>> On Wed, Sep 14, 2011 at 12:15 PM, Holger Brandsmeier
>>> <holger.brandsmeier at sam.math.ethz.ch> wrote:
>>>> Eli,
>>>>
>>>> I tried to replace the linker with g++, but no success.
>>>>
>>>> Out of the three steps:
>>>>  1) build quadratureRulesPy.cpp
>>>>  2) quadraturePy.cpp
>>>>  3) link
>>>>
>>>> I need to use g++ for step 1) (which creates the symbol
>>>> parfem::QuadratureRules<double, 0>::QuadratureRules).
>>>>
>>>> I can then use clang for steps 2 and/or 3 which works nicely. If I use
>>>> clang for step 1 then I always end up with the reported error.
>>>
>>> Hmm... it's possible clang is using the wrong linkage.
>>>
>>> Are you using clang from trunk?  If not, can you try?
>>> (http://clang.llvm.org/get_started.html)
>>>
>>> -Eli
>>>
>>
>> Eli,
>>
>> ok I downloaded it from the SVN and compiled it with the trunk version:
>>
>>> Debug+Asserts/bin/clang --version
>> clang version 3.0 (trunk 139719)
>> Target: i386-pc-linux-gnu
>> Thread model: posix
>>
>> The error stays exactly the same (the compilation takes significantly
>> longer as it is the debug version, but I guess that is to be
>> expected).
>
> Okay... what exactly does the definition of
> parfem::QuadratureRules<double, 0>::QuadratureRules look like?
>
> -Eli
>



-- 
Holger Brandsmeier, SAM, ETH Zürich
http://www.sam.math.ethz.ch/people/bholger




More information about the cfe-dev mailing list