This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Null pointer check elimination


On Sat, Nov 12, 2005 at 10:47:33AM -0800, Per Bothner wrote:
> Per Bothner  wrote:
> >A "function-never-returns-null" attribute doesn't seem like
> >the right mechanism.  Instead, there should be a "never-null"
> >attribute on pointer types.  A "function-never-returns-null" is
> >just a function whose return-type has the "never-null" attribute.
> 
> Gabriel Does Reis wrote:
> >We already have such mechanism: a reference type -- which morally is
> >implemented as a pointer type.
> 
> Andrew Pinski wrote:
> >That was mentioned a way ago as being wrong.  A reference type can be NULL.
> 
> There are other differences, at least in C++: If you assign to a
> pointer, you change the pointer, while if you assign to a reference
> you modify the referenced object.  I.e. if a variable has reference
> type, then the reference itself is constant.

That's two separate features: the first is about how the source code
is interpreted (and that corresponds to informing the debugger that
the object is auto-dereferenced).  The second corresponds to declaring
that a pointer is itself const.

So a C++ reference could be represented as a middle-end pointer type,
provided that it is marked as auto-dereferencing, never null, and
constant.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]