public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/9674: initialization of static class template members just by instantiation does not work
@ 2003-02-12 15:16 benger
  0 siblings, 0 replies; 3+ messages in thread
From: benger @ 2003-02-12 15:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9674
>Category:       c++
>Synopsis:       initialization of static class template members just by instantiation does not work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 12 15:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     benger@zib.de
>Release:        gcc 3.2.2
>Organization:
>Environment:
linux
>Description:
Initialization of static template members appears not to work.
The static initialization function is not called, unless the
static class member is actually used, but it should be
initialized regardless of possible use in the main() program
or somewhere else. SGI CC does correctly initialize the
class member.


litchi:/tmp $ g++ -v a.cc 
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=2 -D__GNUC_PATCHLEVEL__=0 -D__GXX_ABI_VERSION=102 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i386__ a.cc -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -quiet -dumpbase a.cc -version -o /tmp/ccuy0qpK.s
GNU CPP version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) (i386-redhat-linux)
        compiled by GNU C version 3.2 20020903 (Red Hat Linux 8.0 3.2-7).
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2
 /usr/include/c++/3.2/i386-redhat-linux
 /usr/include/c++/3.2/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/include
 /usr/include
End of search list.
 as -V -Qy -o /tmp/cc0QIg5k.o /tmp/ccuy0qpK.s
GNU assembler version 2.13.90.0.2 (i386-redhat-linux) using BFD version 2.13.90.0.2 20020802
 /usr/lib/gcc-lib/i386-redhat-linux/3.2/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crt1.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crti.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtbegin.o -L/usr/lib/gcc-lib/i386-redhat-linux/3.2 -L/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../.. /tmp/cc0QIg5k.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc-lib/i386-redhat-linux/3.2/crtend.o /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../crtn.o
litchi:/tmp $ a.out 
litchi:/tmp $ 
>How-To-Repeat:
compile the following code. it should print "heyda!",
but does not.

////////////////////////////////////////////////////
#include <stdio.h>

template <class x>
struct y
{
static bool z;
static bool a() { puts("heyda!"); return true; }
};

template <class x> 
  bool y<x>::z = y<x>::a();

main()
{
y<int> alpha;

// uncomment to see that using the member triggers a functional before main()
// if (alpha.z) puts("true");
// else         puts("false");
}

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c++/9674: initialization of static class template members just by instantiation does not work
@ 2003-02-26  6:03 mmitchel
  0 siblings, 0 replies; 3+ messages in thread
From: mmitchel @ 2003-02-26  6:03 UTC (permalink / raw)
  To: benger, gcc-bugs, gcc-prs, nobody

Synopsis: initialization of static class template members just by instantiation does not work

State-Changed-From-To: analyzed->closed
State-Changed-By: mmitchel
State-Changed-When: Wed Feb 26 06:03:35 2003
State-Changed-Why:
    Not a defect.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9674


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

* Re: c++/9674: initialization of static class template members just by instantiation does not work
@ 2003-02-14 21:24 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-02-14 21:24 UTC (permalink / raw)
  To: benger, gcc-bugs, gcc-prs, nobody

Synopsis: initialization of static class template members just by instantiation does not work

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Feb 14 21:24:46 2003
State-Changed-Why:
    Behavior confirmed. Don't know, though, what the standard
    says exactly about this. Language lawyers?
    
    W.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9674


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

end of thread, other threads:[~2003-02-26  6:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-12 15:16 c++/9674: initialization of static class template members just by instantiation does not work benger
2003-02-14 21:24 bangerth
2003-02-26  6:03 mmitchel

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