warning when using throw(bad_alloc)

A

arjor

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
 
F

Frank Birbacher

Hi!
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
 
F

Frank Birbacher

Hi!

Frank said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top