This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef.
- From: "rschiele at uni-mannheim dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Nov 2003 13:46:37 -0000
- Subject: [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
To note this first:
I am not sure whether the following is valid C++ code. After inspecting the
C++ standard I did not find a section from which I could conclude clearly that
it is illegal, so I assume it is legal. If my assumption is from here, I'd be
happy if you could point me to the section in the standard that disallows
this.
And now for the bug:
When I typedef an array of a template class to a new typename, new[] does no
longer call the constructor of the template class, but delete[] does call the
destructor. The problem happens only with template classes. This happens with
current cvs HEAD and 3.3 branch.
A simple test case:
extern "C" { int puts(const char *s); }
template<int> struct c {
c() { puts("constructor"); }
~c() { puts("destructor"); }
};
typedef c<0> a[1];
int main() {
a* b = new a[1];
delete b;
}
--
Summary: g++ does not call constructor for array of a template
class that is hidden by a typedef.
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rschiele at uni-mannheim dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i586-suse-linux
GCC host triplet: i586-suse-linux
GCC target triplet: i586-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13023