public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14132] New: static template member definition fails
@ 2004-02-12 19:17 guillaume dot melquiond at ens-lyon dot fr
  2004-02-12 19:37 ` Gabriel Dos Reis
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: guillaume dot melquiond at ens-lyon dot fr @ 2004-02-12 19:17 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]

Hi,

This bug is the same as PR11585 but I'm not convinced by its conclusion. However
I didn't know if I should have reopened the bug or created a new one.

The test-case is:

  template< class T > struct A { static int a; };
  int A< void >::a;

With GCC 3.3 and Intel CC 8.0, the code compiles just fine. But GCC 3.4
(20040211 snapshot) complains: "plouf.cc:2: error: too few
template-parameter-lists". In order for GCC 3.4 to accept the code, "template<>"
must be added in front of the second line (it's the solution suggested in PR11585).

Unfortunately, adding "template<>" does change the meaning of the line since GCC
will not create an instance of "A<void>::a" anymore and the following testcase
will not be linkable:

  template< class T > struct A { static int a; };
  template<> int A< void >::a;
  int main() { A< void >::a = 0; }

  /tmp/ccgh5JJQ.o(.text+0x1e): dans la fonction « main »:
  : undefined reference to `A<void>::a'

It fails to link with GCC 3.3, 3.4 and ICC 8.0. But removing the "template<>"
allows the program to cleanly compile and link with both GCC 3.3 and ICC 8.0. So
what's the solution?

Please consider this bug-report as a wish item for the C++ language improvements
section of http://gcc.gnu.org/gcc-3.4/changes.html since it is quite a common
case when programing with templates and static members.

-- 
           Summary: static template member definition fails
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: guillaume dot melquiond at ens-lyon dot fr
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2004-02-13  1:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-12 19:17 [Bug c++/14132] New: static template member definition fails guillaume dot melquiond at ens-lyon dot fr
2004-02-12 19:37 ` Gabriel Dos Reis
2004-02-12 19:37 ` [Bug c++/14132] " gdr at integrable-solutions dot net
2004-02-12 20:03 ` guillaume dot melquiond at ens-lyon dot fr
2004-02-12 20:27 ` pinskia at gcc dot gnu dot org
2004-02-12 21:42 ` guillaume dot melquiond at ens-lyon dot fr
2004-02-13  0:59 ` gdr at integrable-solutions dot net
2004-02-13  1:01 ` gdr at integrable-solutions dot net

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).