473,503 Members | 1,638 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

nothrow and exceptions

Is it possible for the nothrow form of the new operator to ever throw?
Jul 19 '05 #1
4 4324

"Dave" <be***********@yahoo.com> wrote in message
news:vp***********@news.supernews.com...
Is it possible for the nothrow form of the new operator to ever throw?


Oh Lord, what on Earth is wrong with me...

Is it possible for *PLACEMENT* new to ever throw???

Somebody shoot me!!!
Jul 19 '05 #2

"Dave" <be***********@yahoo.com> wrote in message news:vp***********@news.supernews.com...
Is it possible for the nothrow form of the new operator to ever throw?


No...it has a throw() exception specification on it. If something inside it were to
throw, terminate() would be called.
Jul 19 '05 #3

"Dave" <be***********@yahoo.com> wrote in message news:vp************@news.supernews.com...
Is it possible for *PLACEMENT* new to ever throw???
Sure, the constructor for the object can throw. But the placment allocation
function can not throw. It's defined with a throw() exception specification.
Terminate() would be called even if the the allocation function was replaced
with something that would throw.
Somebody shoot me!!!


Bang.
Jul 19 '05 #4
In article <vp************@news.supernews.com>,
"Dave" <be***********@yahoo.com> wrote:
"Dave" <be***********@yahoo.com> wrote in message
news:vp***********@news.supernews.com...
Is it possible for the nothrow form of the new operator to ever throw?


Oh Lord, what on Earth is wrong with me...

Is it possible for *PLACEMENT* new to ever throw???

Somebody shoot me!!!


<chuckle> Actually your original question has interesting answers. Just
goes to show: there are no dumb questions! :-)

Yes, the nothrow form of the new operator can throw. Well, that's
probably a bit too inflamatory. A new-nothrow expression can throw.
Consider:

struct X
{
X() {throw "up";}
};

void foo()
{
X* xp = new (std::nothrow) X;
}

The new expression in foo() will throw, even though it is using the
nothrow expression. Same deal for placement new.

-Howard
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2453
by: Roger Davis | last post by:
I am trying to use nothrow new() and am encountering what seems to be a bug in the SGI/Irix C++ environment. The following program runs OK under Solaris and Linux, but dumps core at the delete...
1
2368
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
1
2051
by: Lighter | last post by:
Is there a way to write a memory leak detector supporting new(nothrow)? For example, #include <My_Debug_New.h> using namespace std; int main() {
9
3791
by: Alex Vinokur | last post by:
What is difference between delete p; and delete(nothrow)p; ? -- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html
4
6501
by: Alex Vinokur | last post by:
Foo* p = new (nothrow) Foo; Should we use operator delete (p, nothrow) ? Or can we use delete p; ? If we use operator delete (p, nothrow) how to replace it by operator style?
16
13267
by: Dustan | last post by:
This is the biggie that has been keeping me from even trying to use C+ + for more than about 10 seconds: it doesn't work. I've been able to get java and (of course) python programs to compile and...
0
6486
RedSon
by: RedSon | last post by:
Chapter 3: What are the most common Exceptions and what do they mean? As we saw in the last chapter, there isn't only the standard Exception, but you also get special exceptions like...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.