Bug 28599

Summary: multiple definitions of static const member of template class
Product: gcc Reporter: Peter Soetens <peter.soetens>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bangerth, debian-gcc, fang, gcc-bugs, lidaobing, mark, matz, peter.soetens, pinskia, pintaric, rguenth, tbm
Priority: P3    
Version: 4.1.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Peter Soetens 2006-08-04 12:45:35 UTC
The following code snippet (from the boost::ublas library) :

template<class T1, class T2>
struct scalar_divides_assign {
    static const bool computed ;
};

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

gives a defined symbol in the .o file:

$ g++-4.1 -c Ublas.cpp -o Ublas.o; nm -C Ublas.o
00000000 D _ZN21scalar_divides_assignIT_T0_E8computedE

Which is not the case with g++-4.0 and older.
The user gets an "multiple definition of `_ZN5boost7numeric5ublas21scalar_divides_assignIT_T0_E8computedE'"
error at link time.
Comment 1 Martin Michlmayr 2006-08-04 13:50:10 UTC
This is a duplicate of PR28016, which has been fixed already.  What version of the compiler are you using exactly?
Comment 2 Peter Soetens 2006-08-04 14:02:27 UTC
(In reply to comment #1)
> This is a duplicate of PR28016, which has been fixed already.  What version of
> the compiler are you using exactly?
> 

Ubuntu edgy package.

$ g++-4.1 --version
g++-4.1 (GCC) 4.1.2 20060708 (prerelease) (Ubuntu 4.1.1-8ubuntu1)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Same behaviour was reported on a mailinglist for a Debian version.
Comment 3 Martin Michlmayr 2006-08-04 15:10:23 UTC
Has been fixed in Debian and upstream already.  Please talk to your vendor.


*** This bug has been marked as a duplicate of 28016 ***