This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/8227: g++ 3.3: ctors not called in static array initialization


>Number:         8227
>Category:       c++
>Synopsis:       g++ 3.3: ctors not called in static array initialization
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 14 14:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.3 20021014 (experimental)
>Organization:
<organization of PR author (multiple lines)>
>Environment:
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
Architecture: i686

	<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77
>Description:


For the initialization of the static array in the program
below, we generate calls to the class destructor, but there
are no corresponding calls to the constructor.

This is what i get when i run this program:

$ g++ -o x x.cc
$ ./x
dtor 804973c
$

If i change the program so that Cls is not a template class,
then it executes correctly.

>How-To-Repeat:

------------------------
extern "C" int printf (const char*, ...);

template <class T>
struct Cls
{
  Cls () { printf ("ctor %x\n", this); }
  ~Cls () { printf ("dtor %x\n", this); }
};

static Cls<int> xxx[1];

int main ()
{
  return 0;
}
------------------------

>Fix:
	<how to correct or work around the problem, if known (multiple lines)>
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]