public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef.
@ 2003-11-12 13:46 rschiele at uni-mannheim dot de
  2003-11-12 15:23 ` [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called bangerth at dealii dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rschiele at uni-mannheim dot de @ 2003-11-12 13:46 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called
  2003-11-12 13:46 [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef rschiele at uni-mannheim dot de
@ 2003-11-12 15:23 ` bangerth at dealii dot org
  2003-11-12 15:39 ` bangerth at dealii dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2003-11-12 15:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2003-11-12 15:23 -------
This is definitely a bug. gcc never got this right since at
least 2.95.

I think I have seen something similar recently, but can't seem
to find that :-(

W.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2003-11-12 15:23:05
               date|                            |
            Summary|g++ does not call           |constructor for array of a
                   |constructor for array of a  |template class that is
                   |template class that is      |hidden by a typedef is not
                   |hidden by a typedef.        |called


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13023


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

* [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called
  2003-11-12 13:46 [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef rschiele at uni-mannheim dot de
  2003-11-12 15:23 ` [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called bangerth at dealii dot org
@ 2003-11-12 15:39 ` bangerth at dealii dot org
  2003-11-12 15:45 ` rschiele at uni-mannheim dot de
  2004-01-03 13:54 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2003-11-12 15:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2003-11-12 15:39 -------
Never mind, I had thought of PR 12883, but that's a different thing.

W.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13023


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

* [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called
  2003-11-12 13:46 [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef rschiele at uni-mannheim dot de
  2003-11-12 15:23 ` [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called bangerth at dealii dot org
  2003-11-12 15:39 ` bangerth at dealii dot org
@ 2003-11-12 15:45 ` rschiele at uni-mannheim dot de
  2004-01-03 13:54 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rschiele at uni-mannheim dot de @ 2003-11-12 15:45 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rschiele at uni-mannheim dot de  2003-11-12 15:45 -------
Additional note: 
 
replace 
 
delete x; 
 
with 
 
delete[] x; 
 
in the code. Otherwise it is illegal code. But this does not make a difference 
for the problem here. 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13023


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

* [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called
  2003-11-12 13:46 [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef rschiele at uni-mannheim dot de
                   ` (2 preceding siblings ...)
  2003-11-12 15:45 ` rschiele at uni-mannheim dot de
@ 2004-01-03 13:54 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-03 13:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-03 13:54 -------
This is a dup of bug 9782, the problem is not the typedef but the template.

*** This bug has been marked as a duplicate of 9782 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13023


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

end of thread, other threads:[~2004-01-03 13:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-12 13:46 [Bug c++/13023] New: g++ does not call constructor for array of a template class that is hidden by a typedef rschiele at uni-mannheim dot de
2003-11-12 15:23 ` [Bug c++/13023] constructor for array of a template class that is hidden by a typedef is not called bangerth at dealii dot org
2003-11-12 15:39 ` bangerth at dealii dot org
2003-11-12 15:45 ` rschiele at uni-mannheim dot de
2004-01-03 13:54 ` pinskia at gcc dot gnu dot org

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