From: Günter Neià<gneiss@schoenhofer.de>
To: gcc@gcc.gnu.org
Subject: Vector new bug ??
Date: Fri, 12 Oct 2001 02:25:00 -0000 [thread overview]
Message-ID: <3BC6B6FE.69BC3A06@schoenhofer.de> (raw)
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 case:
...
T * p;
if( size == 0 )
p = NULL;
else
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
specify it,
I assume returning NULL (or any unique pointer) should be the default
behaviour in this case
( as malloc( 0 ) does ).
...
Guenter
next reply other threads:[~2001-10-12 2:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-12 2:25 Günter Neià [this message]
2001-10-12 2:55 ` Florian Weimer
2001-10-12 6:45 ` Carlo Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3BC6B6FE.69BC3A06@schoenhofer.de \
--to=gneiss@schoenhofer.de \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).