User account creation filtered due to spam.

Bug 28620 - [4.1 regression] static const member in template class leads to multiple definitions at linktime
Summary: [4.1 regression] static const member in template class leads to multiple defi...
Status: RESOLVED DUPLICATE of bug 28016
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2006-08-06 10:05 UTC by Randolph Chung
Modified: 2006-08-06 13:41 UTC (History)
14 users (show)

See Also:
Host: hppa-unknown-linux
Target: hppa-unknown-linux
Build: hppa-unknown-linux
Known to work: 3.4.6 4.0.4
Known to fail: 4.1.2
Last reconfirmed:

testcase (443 bytes, application/x-compressed-tar)
2006-08-06 10:07 UTC, Randolph Chung

Note You need to log in before you can comment on or make changes to this bug.
Description Randolph Chung 2006-08-06 10:05:50 UTC
with the attached testcase, during linking you get:
test2.o:(.data+0x0): multiple definition of `_ZN3BadIT_E2_yE'
test1.o:(.data+0x0): first defined here

this comes from a template class:
template <class T>
class Bad {
        static const int _y;

template <class T> const int Bad<T>::_y = 1023;

although this seems like a generic c++ problem, it was only observed on hppa-linux and not on other platforms.

this test was simplified from a failure reported in building the quantlib package against g++-4.1. With earlier g++ versions the package builds fine.
Comment 1 Randolph Chung 2006-08-06 10:07:17 UTC
Created attachment 12026 [details]
Comment 2 Martin Michlmayr 2006-08-06 13:41:29 UTC
This has been fixed already, both in GCC's SVN and in Debian's gcc-4.1 package.

The reason you see it on HPPA is that recent version of gcc-4.1 in Debian don't build.  This bug was fixed in -9 but hppa still has -8.  Can you investigate why recent gcc-4.1 in Debian doesn't compile on HPPA?

gcc-4.1 (4.1.1-9) unstable; urgency=low

  * Update to SVN 20060715.
    - Fix PR c++/28016, do not emit uninstantiated static data members.
      Closes: #373895, #376871.

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