public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37656]  New: template specialization of static member constants causes multiple definition error
@ 2008-09-27  1:24 rdelashmit at gmail dot com
  2008-09-27  2:48 ` [Bug c++/37656] " pinskia at gcc dot gnu dot org
  2009-12-26 18:43 ` paolo dot carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: rdelashmit at gmail dot com @ 2008-09-27  1:24 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/37656] template specialization of static member constants causes multiple definition error
  2008-09-27  1:24 [Bug c++/37656] New: template specialization of static member constants causes multiple definition error rdelashmit at gmail dot com
@ 2008-09-27  2:48 ` pinskia at gcc dot gnu dot org
  2009-12-26 18:43 ` paolo dot carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-09-27  2:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-09-27 02:47 -------
IIRC this is not a specialization but rather an instantation.


-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/37656] template specialization of static member constants causes multiple definition error
  2008-09-27  1:24 [Bug c++/37656] New: template specialization of static member constants causes multiple definition error rdelashmit at gmail dot com
  2008-09-27  2:48 ` [Bug c++/37656] " pinskia at gcc dot gnu dot org
@ 2009-12-26 18:43 ` paolo dot carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-26 18:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2009-12-26 18:43 -------
This is definitely invalid. The linkage isn't weak, and you get exactly into
the same problem of a plain:

struct u
{
  static int const v;
};
int const u::v = 42;


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-12-26 18:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-27  1:24 [Bug c++/37656] New: template specialization of static member constants causes multiple definition error rdelashmit at gmail dot com
2008-09-27  2:48 ` [Bug c++/37656] " pinskia at gcc dot gnu dot org
2009-12-26 18:43 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).