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]

[Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef.


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


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