public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11930] New: Cannot define static template struct member
@ 2003-08-15 16:07 schnetter at uni-tuebingen dot de
  2003-08-15 16:36 ` [Bug c++/11930] " bangerth at dealii dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: schnetter at uni-tuebingen dot de @ 2003-08-15 16:07 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Cannot define static template struct member
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: schnetter at uni-tuebingen dot de
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu

I cannot define static members of template structs.  The code 
 
template<int D> 
struct x { 
  static int a; 
}; 
int x<0>::a; 
 
leads to the error message 
 
tmp.cc:5: error: too few template-parameter-lists 
 
The same code compiles fine with g++ 3.3.1.


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

* [Bug c++/11930] Cannot define static template struct member
  2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
@ 2003-08-15 16:36 ` bangerth at dealii dot org
  2003-08-15 18:06 ` schnetter at uni-tuebingen dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2003-08-15 16:36 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


bangerth at dealii dot org changed:

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


------- Additional Comments From bangerth at dealii dot org  2003-08-15 16:36 -------
That's because your code is invalid. You need to write 
  template <> int x<0>::a; 
 
W.


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

* [Bug c++/11930] Cannot define static template struct member
  2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
  2003-08-15 16:36 ` [Bug c++/11930] " bangerth at dealii dot org
@ 2003-08-15 18:06 ` schnetter at uni-tuebingen dot de
  2003-08-15 18:11 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schnetter at uni-tuebingen dot de @ 2003-08-15 18:06 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


schnetter at uni-tuebingen dot de changed:

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


------- Additional Comments From schnetter at uni-tuebingen dot de  2003-08-15 18:06 -------
The proposed solution, namely adding "template<>" in front of the definition 
of the variable a, does not solve the problem.  The compiler now accepts the 
construct, but the object file does not contain a definition of the variable 
a.  (The syntax reminds me of a template specialisation, which is not at all 
what I want.)


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

* [Bug c++/11930] Cannot define static template struct member
  2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
  2003-08-15 16:36 ` [Bug c++/11930] " bangerth at dealii dot org
  2003-08-15 18:06 ` schnetter at uni-tuebingen dot de
@ 2003-08-15 18:11 ` pinskia at gcc dot gnu dot org
  2003-08-15 19:42 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-15 18:11 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at gcc dot gnu dot org changed:

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


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-15 18:11 -------
That is because you need to instantiate the template to get the variable emitted (or use it if on a 
target that supports weak):
template<int D>
struct x {
  static int a;
};
template struct x<0>;
template <> int x<0>::a;


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

* [Bug c++/11930] Cannot define static template struct member
  2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
                   ` (2 preceding siblings ...)
  2003-08-15 18:11 ` pinskia at gcc dot gnu dot org
@ 2003-08-15 19:42 ` bangerth at dealii dot org
  2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
  2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2003-08-15 19:42 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From bangerth at dealii dot org  2003-08-15 19:42 -------
You are right, the syntax I showed is a declaration of an explicit specialization. You 
need to add an initializer to make it a definition. 
W.


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

* [Bug c++/11930] Cannot define static template struct member
  2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
                   ` (3 preceding siblings ...)
  2003-08-15 19:42 ` bangerth at dealii dot org
@ 2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
  2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25  4:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-25 04:12 -------
Mark as a dup of bug 17445.

*** This bug has been marked as a duplicate of 17445 ***

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


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


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

* [Bug c++/11930] Cannot define static template struct member
  2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
                   ` (4 preceding siblings ...)
  2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
@ 2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25  4:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-25 04:12 -------
Reopening to ....

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


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


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

end of thread, other threads:[~2005-04-25  4:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-15 16:07 [Bug c++/11930] New: Cannot define static template struct member schnetter at uni-tuebingen dot de
2003-08-15 16:36 ` [Bug c++/11930] " bangerth at dealii dot org
2003-08-15 18:06 ` schnetter at uni-tuebingen dot de
2003-08-15 18:11 ` pinskia at gcc dot gnu dot org
2003-08-15 19:42 ` bangerth at dealii dot org
2005-04-25  4:13 ` pinskia at gcc dot gnu dot org
2005-04-25  4:13 ` 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).