bug-lib-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Vector new bug ??


From: Günter Neiß
Subject: Vector new bug ??
Date: Wed, 10 Oct 2001 17:15:32 +0200

Hi,

 I found the following bug:

 Using some templates that uses:

 template<class T>
 ....
   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
gdb).

 Ok, the workaroung is to check for this cas:
 
 ...
  T * p;
  if( size == 0 )
    p = NULL;
   else
    p = new T[ size ];
 ...

 But I assume that this behaviour 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
specify it, 
 I assume returning NULL should be the default behaviour in this case
 ( as malloc( 0 ) does ).

Guenter

Attachment: smime.p7s
Description: Kryptographische Unterschrift mit S/MIME


reply via email to

[Prev in Thread] Current Thread [Next in Thread]