This is the mail archive of the
mailing list for the GCC project.
Vector new bug ??
- To: gcc at gcc dot gnu dot org
- Subject: Vector new bug ??
- From: Günter Neiß <gneiss at schoenhofer dot de>
- Date: Fri, 12 Oct 2001 11:25:18 +0200
I found the following bug:
Using some templates that uses:
t * p = new T[ size ];
Everything works fine, as long as 'size' isn't 0.
In that case I got an exeption inside 'builin vector new' (shown by
Ok, the workaroung is to check for this case:
T * p;
if( size == 0 )
p = NULL;
p = new T[ size ];
But I assume that this behaviour (or a similar one) should already
implemented inside (vector) new !
I assume this, because this code was ported from Borland C++ (and works
under MS-C++ as well).
I am not shure what the C++ standard says to this, but if it don't
I assume returning NULL (or any unique pointer) should be the default
behaviour in this case
( as malloc( 0 ) does ).