public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sebastian dot huber at embedded-brains dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/44647] std::nothrow and std::bad_alloc are coupled
Date: Wed, 23 Jun 2010 15:02:00 -0000	[thread overview]
Message-ID: <20100623150218.14136.qmail@sourceware.org> (raw)
In-Reply-To: <bug-44647-16781@http.gcc.gnu.org/bugzilla/>



------- Comment #2 from sebastian dot huber at embedded-brains dot de  2010-06-23 15:02 -------
(In reply to comment #1)
> (In reply to comment #0)
> > The std::bad_alloc definitions should be placed into a
> > separate file.
> 
> IIUC that wouldn't work, <new> is required to declare bad_alloc, so if
> bad_alloc was moved to a separate file, the parts of the library which need
> nothrow_t, new_handler and operator new etc. would still have to include <new>,
> which would still have to include bad_alloc.
> 
> The way to achieve what you want is to put everything except bad_alloc in a
> separate file, and include that file instead of <new> when bad_alloc is not
> needed.
> 

There is nothing wrong with <new>.  The problem is new_handler.cc.

Suppose you use

#include <new>

int *p = new (std::nothrow) int;

this will use the operator new implementation in new_opnt.cc.  This one uses
__new_handler which is now coupled with std::bad_alloc.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44647


  parent reply	other threads:[~2010-06-23 15:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23 14:35 [Bug libstdc++/44647] New: " sebastian dot huber at embedded-brains dot de
2010-06-23 14:57 ` [Bug libstdc++/44647] " redi at gcc dot gnu dot org
2010-06-23 15:02 ` sebastian dot huber at embedded-brains dot de [this message]
2010-06-23 15:14 ` redi at gcc dot gnu dot org
2010-06-23 15:20 ` sebastian dot huber at embedded-brains dot de
2010-06-23 15:24 ` redi at gcc dot gnu dot org
     [not found] <bug-44647-4@http.gcc.gnu.org/bugzilla/>
2010-10-05  9:42 ` paolo at gcc dot gnu.org
2010-10-05  9:44 ` paolo.carlini at oracle dot com
2010-10-05  9:44 ` paolo.carlini at oracle dot com

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=20100623150218.14136.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).