This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/37656] New: template specialization of static member constants causes multiple definition error
- From: "rdelashmit at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Sep 2008 01:23:05 -0000
- Subject: [Bug c++/37656] New: template specialization of static member constants causes multiple definition error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
A specialization of a static member included from multiple cpp files generates
multiple definition errors. Example follows, requires 3 files (header and 2
.cpp files which include it). Tested on linux with gcc 4.2.3 (Ubuntu
4.2.3-2ubuntu7) and osx with gcc 4.0.1 (Apple Inc. build 5465).
Compile with: g++ -Wall -g -o a a.cpp b.cpp
// a.h
struct a{};
template <typename T>
struct t
{
static int const v;
};
template <> int const t<a>::v = 42;
// a.cpp
#include "a.h"
// b.cpp
#include "a.h"
--
Summary: template specialization of static member constants
causes multiple definition error
Product: gcc
Version: 4.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rdelashmit at gmail dot com
GCC build triplet: i486-linux-gnu
GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37656