home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!ames!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!lri.FR!yb
- From: yb@lri.FR
- Newsgroups: gnu.g++.bug
- Subject: badly generated operator new in template
- Date: 26 Jan 1993 22:06:10 -0500
- Organization: GNUs Not Usenet
- Lines: 56
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-g++@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <199301261525.AA26111@lri.lri.fr>
-
- 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 |
- |###### ### |
- +---------------------------------------------------------------+
-
-