public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31044] New: Compilation fails on definition of a static template class member
@ 2007-03-05 16:50 indiana dot jones at gmx dot at
2007-03-09 5:01 ` [Bug c++/31044] " bangerth at dealii dot org
2007-07-21 8:58 ` pinskia at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: indiana dot jones at gmx dot at @ 2007-03-05 16:50 UTC (permalink / raw)
To: gcc-bugs
The following sample fails to compile:
template<class _Type, int _Val>
class Container
{
static const _Type Value = _Val;
};
template<class _Type>
class Test
{
static const uint Value = 2;
static const Container<_Type, Value> m_Test;
};
template<class _Type>
const Container<_Type, Test<_Type>::Value> Test<_Type>::m_Test;
The compiler says:
Test.cpp:29: error: conflicting declaration 'const Container<_Type,
Test<_Type>::Value> Test<_Type>::m_Test'
Test.cpp:24: error: 'Test<_Type>::m_Test' has a previous declaration as 'const
Container<_Type, 2> Test<_Type>::m_Test'
Test.cpp:29: error: declaration of 'const Container<_Type, 2>
Test<_Type>::m_Test' outside of class is not definition
The problem is the Test<_Type>::Value in the definition - if i replace it with
2 it is working. I tried the sample above with Visual Studio 2005 and Comeau
4.3.3 (Online) and both compile without any error.
--
Summary: Compilation fails on definition of a static template
class member
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: indiana dot jones at gmx dot at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31044
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/31044] Compilation fails on definition of a static template class member
2007-03-05 16:50 [Bug c++/31044] New: Compilation fails on definition of a static template class member indiana dot jones at gmx dot at
@ 2007-03-09 5:01 ` bangerth at dealii dot org
2007-07-21 8:58 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2007-03-09 5:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from bangerth at dealii dot org 2007-03-09 05:01 -------
Confirmed, though I believe this is a duplicate of some other PR. This
is not a regression.
Somewhat smaller:
--------------
template<int i> class C {};
template<class T>
class X
{
static const unsigned int Value = 2;
static const C<Value> m_X;
};
template<class T>
const C<X<T>::Value> X<T>::m_X;
--------------------
g/x> c++ -c x.cc
x.cc:11: error: conflicting declaration 'const C<X<T>::Value> X<T>::m_X'
x.cc:7: error: 'X<T>::m_X' has a previous declaration as 'const C<2> X<T>::m_X'
x.cc:11: error: declaration of 'const C<2> X<T>::m_X' outside of class is not
definition
The last error happens because the last line of code is indeed not a
definition.
To avoid it, one would need to specify an initializer.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2007-03-09 05:01:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31044
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/31044] Compilation fails on definition of a static template class member
2007-03-05 16:50 [Bug c++/31044] New: Compilation fails on definition of a static template class member indiana dot jones at gmx dot at
2007-03-09 5:01 ` [Bug c++/31044] " bangerth at dealii dot org
@ 2007-07-21 8:58 ` pinskia at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-21 8:58 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31044
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-21 8:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-05 16:50 [Bug c++/31044] New: Compilation fails on definition of a static template class member indiana dot jones at gmx dot at
2007-03-09 5:01 ` [Bug c++/31044] " bangerth at dealii dot org
2007-07-21 8:58 ` pinskia at gcc dot gnu dot org
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).