Re: C++: not defining thrown exceptions produces error, but only on hppa platform
On Thu, 12 Sep 2002, Daniel Lutz wrote:
> Here are the error messages:
>
> g++ -DHAVE_CONFIG_H -I. -I. -I../.. -g -O2 -c -o XBase.o `test -f
> XBase.cpp || echo './'`XBase.cpp
> In file included from XBase.cpp:15:
> XBase.h:33: looser throw specifier for `virtual XBase::~XBase()'
> /usr/include/g++-v3/exception:53: overriding `virtual
> std::exception::~exception() throw ()'
> XBase.h:36: looser throw specifier for `virtual const char*
> XBase::what()
> const'
> /usr/include/g++-v3/exception:56: overriding `virtual const char*
> std::exception::what() const throw ()'
It is saying that you have overridden a virtual method that has a
restricted throw list and made the throw list broader. (ie you went from
method does not throw anything to method can throw anything)
You need to change:
> virtual ~XBase();
> virtual const char* what() const;
To
virtual ~XBase() throw();
virtual const char* what() const throw();
and probably also change the function body too.
Jason
Reply to: