Thread View: gnu.g++.bug
1 messages
1 total messages
Started by yb
Wed, 27 Jan 1993 03:06
badly generated operator new in template
Author: yb
Date: Wed, 27 Jan 1993 03:06
Date: Wed, 27 Jan 1993 03:06
55 lines
2236 bytes
2236 bytes
g++ 2.3.3 generates incorrect operator new when it is defined in a template class.
Looking at the assembly code, I noticed that the allocated-size is not loaded
from the good register.
The following piece of code illustrates this problem :
% cat foo.cc
#include <stddef.h>
#include <stdio.h>
template <class T>
class A {
public:
T v;
void* operator new (size_t);
};
template <class T> void*
A<T> :: operator new (size_t s)
{
printf ("%d\n", s);
return new char [s];
}
main ()
{
printf ("%d\n", sizeof(A<int>));
A<int>* a = new A<int>;
}
% gcc -v
Reading specs from /usr/local/gnu/lib/gcc-lib/hp700-hpux/2.3.3/specs
gcc version 2.3.3
% gcc foo.cc
% a.out
4
-278528
Virtual memory exceeded in `new'
----------------
Interesting !
+--------------------------+------------------------------------+
| | E-mail : yb@lri.lri.fr |
| Yves Berteaud | yb@FRLRI61.BITNET |
| | |
| +-=-+-=-+ | Voice : 33 (1) 69-41-69-10 |
| | Fax : 33 (1) 69-41-65-86 |
+--------------------------+------------------------------------+
| ###### ** |
| ## # Laboratoire de recherche en informatique |
| ## # ## Batiment 490 |
| ## # ## Universite de Paris-Sud |
| ## #### ## 91405 ORSAY Cedex |
| ###### ## ## FRANCE |
|###### ### |
+---------------------------------------------------------------+
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads