This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9782: constructor not called on higher-dimensional arrays of template types
- From: bangerth at dealii dot org
- To: Michael dot J dot Kenny at saic dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: 20 Feb 2003 23:18:14 -0000
- Subject: Re: c++/9782: constructor not called on higher-dimensional arrays of template types
- Reply-to: bangerth at dealii dot org, Michael dot J dot Kenny at saic dot com, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Old Synopsis: constructor not called on typedef'd templated object
New Synopsis: constructor not called on higher-dimensional arrays of template types
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu Feb 20 23:18:14 2003
State-Changed-Why:
Confirmed with 2.95...present mainline. Problem is more
convenient to see here:
----------------------------------
extern "C" void printf(char *, ...);
template <int>
struct A {
A() {printf("A::A()\n");}
};
struct B {
B() {printf("B::B()\n");}
};
int main () {
new A<0>[1][1]; // constructor apparently _not_ called
new B [1][1]; // constructor _is_ called
}
-------------------------------
A and B differ only in that one is a template and the
other is not. Yet, only the constructor of B is called:
x/bug> /home/bangerth/bin/gcc-3.4-pre/bin/c++ test.C
x/bug> ./a.out
B::B()
If we have a 1d array, both constructors run, as expected.
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9782