[Bug c++/15394] New: g++ fails to produce a static definition for static template member

razeh at yahoo dot com gcc-bugzilla@gcc.gnu.org
Thu May 13 01:00:00 GMT 2004


I am having trouble getting gcc 3.4.0 to produce a static definition
for a static member of a template class.  I have been following
the example giving in bug report 15006
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15006) for creating
the static definition.  However, after adding a main to the sample
code that references the static variables it appears to compile but not link.


The compiler:
razeh@terk:/home/host/razeh/testing$ gcc -v
Reading specs from
/usr/local/packages/gcc-3.4.0/lib/gcc/sparc-sun-solaris2.8/3.4.0/specs
Configured with: /home/host/ewolfe/gcc-3.4.0/configure
--prefix=/usr/local/packages/gcc-3.4.0 --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 3.4.0

The test case:

template<class K, class V> class EST_THash;
class EST_String
{
public:
  void foobar() { }
};
class EST_Regex
{
public:
  void bar() { }
};
template<class K, class V>
class EST_THash {
public:
  static V Dummy_Value;
  static K Dummy_Key;
};

template <> EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
template <> EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;
template EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
template EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;

int main(int argc, char *argv[])
{
  EST_THash<EST_String, EST_Regex*> foo;
  foo.Dummy_Value->bar();
}

The problem:
razeh@terk:/home/host/razeh/testing$ g++ missingStatic3.C
Undefined                       first referenced
 symbol                             in file
EST_THash<EST_String, EST_Regex*>::Dummy_Value       /var/tmp//cccPQZFu.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

-- 
           Summary: g++ fails to produce a static definition for static
                    template member
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: razeh at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8/
  GCC host triplet: sparc-sun-solaris2.8/
GCC target triplet: sparc-sun-solaris2.8/


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



More information about the Gcc-bugs mailing list