I have some software that uses the BOOST matrix library UBLAS (1.33.1).  This
software compiles and links with GCC 4.1.1 (Debian Linux system - GNU ld) but
gives linking errors with GCC 4.2:

substitution.o:(.data+0x0): multiple definition of
`_ZN5boost7numeric5ublas21scalar_divides_assignIT_T0_E8computedE'
alignment.o:(.data+0x0): first defined here

Here is from the definition of the static const member of a template class in
boost/numeric/ublas/functional.hpp:

template<class T1, class T2>
struct scalar_divides_assign:
public scalar_binary_assign_functor<T1, T2> {
      ... stuff ...
};

template<class T1, class T2>
const bool scalar_divides_assign<T1,T2>::computed = true;

GCC 4.2, but not 4.1 actually emits this constant in the global data section. 
With 4.2:

$ nm alignment.o | grep divides
0000000000000180 t
_GLOBAL__I__ZN5boost7numeric5ublas21scalar_divides_assignIT_T0_E8computedE
0000000000000000 D
_ZN5boost7numeric5ublas21scalar_divides_assignIT_T0_E8computedE

With 4.1 neither of these two symbols (or is it one symbol, mentioned twice?)
is emitted.


-- 
           Summary: GCC 4.2 emitting static template constants as global
                    symbols?
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bredelin at ucla dot edu
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28016

Reply via email to