This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: cni-changes documented?
- From: Tom Tromey <tromey at redhat dot com>
- To: "Boehm, Hans" <hans dot boehm at hp dot com>
- Cc: "'Andrew Haley'" <aph at redhat dot com>, Adam Megacz <adam at megacz dot com>,java at gcc dot gnu dot org
- Date: 18 Mar 2004 10:02:50 -0700
- Subject: Re: cni-changes documented?
- References: <0C3EFB691636964BBF914AE56AE83A89501FFE@hplex4.hpl.hp.com>
- Reply-to: tromey at redhat dot com
>>>>> "Hans" == Boehm, Hans <hans.boehm@hp.com> writes:
Hans> (I'm not sure whether the smart pointers to implement
Hans> null-pointer checks are implemented as C++ source.)
Hans> At least in my experience, a general problem with C++ "smart pointers"
Hans> is that they only behave 95% like pointers, and it's usually still
Hans> possible to get premature deallocation if you try, or if you try to
Hans> manually optimize too aggressively.
I think our plan for smart pointer is just a very thin wrapper around
the pointer to do null checking:
template<typename T>
class ref
{
private:
T *val;
public:
... constructors and stuff...
T *operator () const
{
#ifdef NO_SEGV_HANDLER
if (! val) throw new NullPointerException();
#endif
return val;
}
};
The hope is that the overhead from this approach will be very small.
Tom