By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

warning when using throw(bad_alloc)

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.