473,378 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

warning when using throw(bad_alloc)

hello guys

i get the following warning when i try to try an throw an exception
given by the new command.

declaration:
void CopyTree(Vertex*& copy, const Vertex* originalTree)
throw(bad_alloc);

defenition:
void BinSearchTree::CopyTree(Vertex*& copy, const Vertex*
originalTree) throw(bad_alloc)
{
if (originalTree == NULL)
copy = NULL;

else {
copy = new Vertex(originalTree->getElement());
CopyTree(copy->left_, originalTree->left_);
CopyTree(copy->right_, originalTree->right_);
}
}

i get the following warning: warning C4290: C++ exception
specification ignored except to indicate a function is not
__declspec(nothrow)

any help would be appreciated
Jun 27 '08 #1
3 2759
Hi!

arjor schrieb:
declaration:
void CopyTree(Vertex*& copy, const Vertex* originalTree)
throw(bad_alloc);
[snip]
i get the following warning: warning C4290: C++ exception
specification ignored except to indicate a function is not
__declspec(nothrow)
It is just that msvc doesn't support exception specifications at all.
You could as well delete the "throw(bad_alloc)" part from your declaration.

Frank
Jun 27 '08 #2
Hi!

Frank Birbacher schrieb:
It is just that msvc doesn't support exception specifications at all.
You could as well delete the "throw(bad_alloc)" part from your declaration.
Actually: it does support "throw()" which is actually quite important.
But MSVC recognizes nothing in between, that means it supports only no
throw and throw anything.

Frank
Jun 27 '08 #3
Frank Birbacher <bl************@gmx.netkirjutas:
Hi!

Frank Birbacher schrieb:
>It is just that msvc doesn't support exception specifications at all.
You could as well delete the "throw(bad_alloc)" part from your
declaration.

Actually: it does support "throw()" which is actually quite important.
But MSVC recognizes nothing in between, that means it supports only no
throw and throw anything.
And based on apparent consensus of previous threads on that issue, this
behavior (differentiating only no-throw and throw-anything) seems to be
widely recognized as the only one which makes sense, albeit not conforming
with the Standard.

Paavo
Jun 27 '08 #4

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

Similar topics

3
by: jy | last post by:
I have a C++ program which is "purify" clean, but crashes (called terminate) when run out of memory on linux 2.4.27. From the core file, the crashes happen after I throw an exception (after malloc...
3
by: Tony Johansson | last post by:
Hello! When you allocate object dynamically which mean on the heap I find that a problem when using exception. What is the prefer method to handle this kind of problem. //Tony
26
by: HP | last post by:
Hi guys i wana remove this warning which i am getting during my codcomilation. the warning is - Possible use of null pointer 'PnoSytGenericTest::_response' in left argument to operator '->'
5
by: Gary Wessle | last post by:
Hi I am getting this error when running a very similar code like the below, it is made for illustration only. thanks *************************************** **************** error...
14
by: Mohsen | last post by:
Hello everyone, In my program, I have to define many pointers and when I want to compile my program (in UNIX), it gives me the following error: terminate called after throwing an instance of...
5
by: desktop | last post by:
I have made the following new_handler that I set in main: /* ================== new_handler ================== */ void no_mem() { std::cerr << "out of memory\n"; throw std::bad_alloc();...
71
by: desktop | last post by:
I have read in Bjarne Stroustrup that using malloc and free should be avoided in C++ because they deal with uninitialized memory and one should instead use new and delete. But why is that a...
4
by: simbasaurus | last post by:
Hello! I am trying to make sure that I clean up and free all the resources that I allocate in my code. In the following code, I am assuming that if new throws bad_alloc, than the value of...
5
by: George2 | last post by:
Hello everyone, I am wondering except when there is no memory on heap, are there any other situations when we will get bad_alloc exceptions? For example, invalid input of the size (e.g. very...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.