libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libtool, llvm-gcc, failing C++ exceptions


From: Bob Friesenhahn
Subject: Re: libtool, llvm-gcc, failing C++ exceptions
Date: Sun, 10 Jan 2010 22:32:15 -0600 (CST)
User-agent: Alpine 2.01 (GSO 1266 2009-07-14)

On Sun, 10 Jan 2010, Ralf Wildenhues wrote:

My main comment is that it would be useful if the thrown class is
derived from std:exception (or one of its standard derived classes)
in order to flush out any issues which may stem from possible
partial template instantiation in libstdc++ (or pre-compiled
headers) as well as in the test translation unit.

OK, sounds useful.  Would that entail more than just something like
this incremental addition?

I think that the virtual what() method needs to be provided or else you have only a partially implemented class:

class MyException : public std::exception
{
  public;
    MyException() {}

  virtual const char *what() const throw()
  {
     return "My message";
  }
};

But this is a better class to test with since it uses more standard library stuff and is therefore more likely to fail if something is wrong:

#include <exception>
#include <string>
class MyException : public std::exception
{
  public;
    MyException(std::string str)
     : message(str)
    {
    }

  virtual const char *what() const throw()
  {
     return message.c_str();
  }

  private:
    std::string message;
};

Which can be thrown with

  throw MyException("My message");

Bob
--
Bob Friesenhahn
address@hidden, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]