This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/37656] New: template specialization of static member constants causes multiple definition error


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]